3 This file is part of the Free Pascal run time library.
4 Copyright (c) 1999-2000 by the Free Pascal development team
6 See the file COPYING.FPC, included in this distribution,
7 for details about the copyright.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 **********************************************************************}
16 SOCK_STREAM = 1; { stream (connection) socket }
17 SOCK_DGRAM = 2; { datagram (conn.less) socket }
18 SOCK_RAW = 3; { raw socket }
19 SOCK_RDM = 4; { reliably-delivered message }
20 SOCK_SEQPACKET = 5; { sequential packet socket }
23 AF_UNIX = 1; { Unix domain sockets }
24 AF_INET = 2; { Internet IP Protocol }
27 PF_UNSPEC = AF_UNSPEC;
33 { For setsockoptions(2) }
49 { To add : SO_REUSEPORT 15 }
57 { Security levels - as per NRL IPv6 - don't actually do anything }
59 SO_SECURITY_AUTHENTICATION = 22;
60 SO_SECURITY_ENCRYPTION_TRANSPORT= 23;
61 SO_SECURITY_ENCRYPTION_NETWORK = 24;
73 SO_DEBUG =$0001; { turn on debugging info recording }
74 SO_ACCEPTCONN =$0002; { socket has had listen() }
75 SO_REUSEADDR =$0004; { allow local address reuse }
76 SO_KEEPALIVE =$0008; { keep connections alive }
77 SO_DONTROUTE =$0010; { just use interface addresses }
78 SO_BROADCAST =$0020; { permit sending of broadcast msgs }
79 SO_USELOOPBACK =$0040; { bypass hardware when possible }
80 SO_LINGER =$0080; { linger on close if data present }
81 SO_OOBINLINE =$0100; { leave received OOB data in line }
82 SO_REUSEPORT =$0200; { allow local address & port reuse }
83 SO_TIMESTAMP =$0400; { timestamp received dgram traffic }
86 * Additional options, not kept in so_options.
88 SO_SNDBUF =$1001; { send buffer size }
89 SO_RCVBUF =$1002; { receive buffer size }
90 SO_SNDLOWAT =$1003; { send low-water mark }
91 SO_RCVLOWAT =$1004; { receive low-water mark }
92 SO_SNDTIMEO =$1005; { send timeout }
93 SO_RCVTIMEO =$1006; { receive timeout }
94 SO_ERROR =$1007; { get error status and clear }
95 SO_TYPE =$1008; { get socket type }
98 SHUT_RD =0; { shut down the reading side }
99 SHUT_WR =1; { shut down the writing side }
100 SHUT_RDWR =2; { shut down both sides }
106 { Two constants to determine whether part of soket is for in or output }
111 TSockAddr = packed Record
116 family:word; { was byte, fixed }
118 data :array [0..13] of char;
121 TInetSockAddr = packed Record
125 pad :array [1..8] of byte; { to get to the size of sockaddr... }
128 TSockArray = Array[1..2] of Longint;
133 {Basic Socket Functions}
134 Function Socket(Domain,SocketType,Protocol:Longint):Longint;
135 Function Send(Sock:Longint;Var Addr;AddrLen,Flags:Longint):Longint;
136 Function Recv(Sock:Longint;Var Addr;AddrLen,Flags:Longint):Longint;
137 Function Bind(Sock:Longint;Var Addr;AddrLen:Longint):Boolean;
138 Function Listen (Sock,MaxConnect:Longint):Boolean;
139 Function Accept(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
140 Function Connect(Sock:Longint;Var Addr;Addrlen:Longint):boolean;
141 Function Shutdown(Sock:Longint;How:Longint):Longint;
142 Function GetSocketName(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
143 Function GetPeerName(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
144 Function SetSocketOptions(Sock,Level,OptName:Longint;Var OptVal;optlen:longint):Longint;
145 Function GetSocketOptions(Sock,Level,OptName:Longint;Var OptVal;Var optlen:longint):Longint;
146 Function SocketPair(Domain,SocketType,Protocol:Longint;var Pair:TSockArray):Longint;
149 Procedure Sock2Text(Sock:Longint;Var SockIn,SockOut:Text);
151 {Untyped File Support}
152 Procedure Sock2File(Sock:Longint;Var SockIn,SockOut:File);
154 {Better Pascal Calling, Overloaded Functions!}
155 Function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:File):Boolean;
156 Function Accept(Sock:longint;var addr:TInetSockAddr;var SockIn,SockOut:text):Boolean;
157 Function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:text):Boolean;
158 Function Connect(Sock:longint;const addr:TInetSockAddr;var SockIn,SockOut:file):Boolean;
162 Revision 1.1 2002/02/19 08:25:28 sasu
165 Revision 1.1.2.1 2000/09/10 16:12:05 marco
166 BSD SO_ constants added
168 Revision 1.1 2000/07/13 06:30:48 michael
171 Revision 1.7 2000/06/19 13:31:46 michael
172 + Corrected GetSocketOptions
174 Revision 1.6 2000/06/02 17:30:43 marco
175 * added some constants for getsocketoptions under a linux define.
176 Allows server example to work ok.
178 Revision 1.5 2000/02/09 16:59:31 peter
181 Revision 1.4 2000/01/07 16:41:36 daniel
184 Revision 1.3 2000/01/07 16:32:25 daniel
185 * copyright 2000 added