Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / rtl / inc / socketsh.inc
bloba52217bb74b7ea3cdd7ed7d27b1cbc6e1f50e9a5
2     $Id$
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  **********************************************************************}
14 Const
15   { Socket Types }
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     }
22   AF_UNSPEC       = 0;
23   AF_UNIX         = 1;      { Unix domain sockets          }
24   AF_INET         = 2;      { Internet IP Protocol         }
26   {  Protocol Families }
27   PF_UNSPEC       = AF_UNSPEC;
28   PF_UNIX         = AF_UNIX;
29   PF_INET         = AF_INET;
31 {$Ifdef Linux}
32 {$ifndef BSD}
33 { For setsockoptions(2) }
34          SOL_SOCKET  =   1;
35          SO_DEBUG    =   1;
36          SO_REUSEADDR=   2;
37          SO_TYPE     =   3;
38          SO_ERROR    =   4;
39          SO_DONTROUTE=   5;
40          SO_BROADCAST=   6;
41          SO_SNDBUF   =   7;
42          SO_RCVBUF   =   8;
43          SO_KEEPALIVE=   9;
44          SO_OOBINLINE=   10;
45          SO_NO_CHECK =   11;
46          SO_PRIORITY =   12;
47          SO_LINGER   =   13;
48          SO_BSDCOMPAT=   14;
49 { To add :         SO_REUSEPORT 15 }
50          SO_PASSCRED=    16;
51          SO_PEERCRED=    17;
52          SO_RCVLOWAT=    18;
53          SO_SNDLOWAT=    19;
54          SO_RCVTIMEO=    20;
55          SO_SNDTIMEO=    21;
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;
63          SO_BINDTODEVICE=   25;
65 { Socket filtering }
67          SO_ATTACH_FILTER=  26;
68          SO_DETACH_FILTER=  27;
70          SO_PEERNAME     =  28;
71 {$ELSE}
72         SOL_SOCKET = $FFFF;
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.
87  }
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 }
102 {$endif}
103 {$ENDIF}
105 const
106   { Two constants to determine whether part of soket is for in or output }
107   S_IN = 0;
108   S_OUT = 1;
110 Type
111   TSockAddr = packed Record
112     {$ifdef BSD}
113      len : byte;
114      family:byte;
115     {$ELSE}
116      family:word;  { was byte, fixed }
117     {$ENDIF}
118     data  :array [0..13] of char;
119     end;
121   TInetSockAddr = packed Record
122     family:Word;
123     port  :Word;
124     addr  :Cardinal;
125     pad   :array [1..8] of byte; { to get to the size of sockaddr... }
126     end;
128   TSockArray = Array[1..2] of Longint;
131   SocketError: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;
148 {Text Support}
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;
161   $Log$
162   Revision 1.1  2002/02/19 08:25:28  sasu
163   Initial revision
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
169   + Initial import
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
179     * truncated log
181   Revision 1.4  2000/01/07 16:41:36  daniel
182     * copyright 2000
184   Revision 1.3  2000/01/07 16:32:25  daniel
185     * copyright 2000 added