| 1 | Unit PMWSock;
|
|---|
| 2 |
|
|---|
| 3 | {
|
|---|
| 4 | /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
|
|---|
| 5 | *
|
|---|
| 6 | * This header file corresponds to version 1.1 of the Windows Sockets specification.
|
|---|
| 7 | *
|
|---|
| 8 | * This file includes parts which are Copyright (c) 1982-1986 Regents
|
|---|
| 9 | * of the University of California. All rights reserved. The
|
|---|
| 10 | * Berkeley Software License Agreement specifies the terms and
|
|---|
| 11 | * conditions for redistribution.
|
|---|
| 12 | */
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | Interface
|
|---|
| 16 |
|
|---|
| 17 | Uses Os2Def;
|
|---|
| 18 |
|
|---|
| 19 | Type TSOCKET=LongWord;
|
|---|
| 20 |
|
|---|
| 21 | Const FD_SETSIZE = 64;
|
|---|
| 22 |
|
|---|
| 23 | Type TFDSET=Record
|
|---|
| 24 | fd_count:Word;
|
|---|
| 25 | fd_array:Array[0..FD_SETSIZE-1] Of TSOCKET;
|
|---|
| 26 | End;
|
|---|
| 27 |
|
|---|
| 28 | timeval=Record
|
|---|
| 29 | tv_sec:LongInt;
|
|---|
| 30 | tv_usec:LongInt;
|
|---|
| 31 | End;
|
|---|
| 32 |
|
|---|
| 33 | Const
|
|---|
| 34 | IOCPARM_MASK = $7f;
|
|---|
| 35 | IOC_VOID = $20000000;
|
|---|
| 36 | IOC_OUT = $40000000;
|
|---|
| 37 | IOC_IN = $80000000;
|
|---|
| 38 | IOC_INOUT = IOC_IN Or IOC_OUT;
|
|---|
| 39 | FIONREAD = IOC_OUT Or ((Longint(SizeOf(Longint)) And IOCPARM_MASK) Shl 16) Or
|
|---|
| 40 | (Longint(Byte('f')) Shl 8) Or 127;
|
|---|
| 41 | FIONBIO = IOC_IN Or ((Longint(SizeOf(Longint)) And IOCPARM_MASK) Shl 16) Or
|
|---|
| 42 | (Longint(Byte('f')) shl 8) Or 126;
|
|---|
| 43 | FIOASYNC = IOC_IN Or ((Longint(SizeOf(Longint)) And IOCPARM_MASK) Shl 16) Or
|
|---|
| 44 | (Longint(Byte('f')) Shl 8) Or 125;
|
|---|
| 45 |
|
|---|
| 46 | Type
|
|---|
| 47 | PCharArray=^TCharArray;
|
|---|
| 48 | TCharArray=Array[0..0] Of PChar;
|
|---|
| 49 |
|
|---|
| 50 | hostent=Record
|
|---|
| 51 | h_name:PChar; /* official name of host */
|
|---|
| 52 | h_aliases:PCharArray; /* alias list */
|
|---|
| 53 | h_addrtype:LongInt; /* host address type */
|
|---|
| 54 | h_length:LongInt; /* length of address */
|
|---|
| 55 | h_addr_list:PCharArray; /* list of addresses from name server */
|
|---|
| 56 | //h_addr h_addr_list[0] /* address, for backward compatiblity */
|
|---|
| 57 | End;
|
|---|
| 58 | phostent=^hostent;
|
|---|
| 59 |
|
|---|
| 60 | netent=Record
|
|---|
| 61 | n_name:PChar;
|
|---|
| 62 | n_aliases:PCharArray;
|
|---|
| 63 | n_addrtype:LongInt;
|
|---|
| 64 | n_net:LongWord;
|
|---|
| 65 | End;
|
|---|
| 66 | pnetent=^netent;
|
|---|
| 67 |
|
|---|
| 68 | servent=Record
|
|---|
| 69 | s_name:PChar;
|
|---|
| 70 | s_aliases:PCharArray;
|
|---|
| 71 | s_port:LongInt;
|
|---|
| 72 | s_proto:PChar;
|
|---|
| 73 | End;
|
|---|
| 74 | pservent=^servent;
|
|---|
| 75 |
|
|---|
| 76 | protoent=Record
|
|---|
| 77 | p_name:PChar;
|
|---|
| 78 | p_aliases:PCharArray;
|
|---|
| 79 | p_proto:LongInt;
|
|---|
| 80 | End;
|
|---|
| 81 | pprotoent=^protoent;
|
|---|
| 82 |
|
|---|
| 83 | Const
|
|---|
| 84 | IPPROTO_IP =0; /* dummy for IP */
|
|---|
| 85 | IPPROTO_ICMP =1; /* control message protocol */
|
|---|
| 86 | IPPROTO_GGP =2; /* gateway^2 (deprecated) */
|
|---|
| 87 | IPPROTO_TCP =6; /* tcp */
|
|---|
| 88 | IPPROTO_PUP =12; /* pup */
|
|---|
| 89 | IPPROTO_UDP =17; /* user datagram protocol */
|
|---|
| 90 | IPPROTO_IDP =22; /* xns idp */
|
|---|
| 91 | IPPROTO_ND =77; /* UNOFFICIAL net disk proto */
|
|---|
| 92 | IPPROTO_RAW =255; /* raw IP packet */
|
|---|
| 93 | IPPROTO_MAX =256;
|
|---|
| 94 |
|
|---|
| 95 | IPPORT_ECHO =7;
|
|---|
| 96 | IPPORT_DISCARD =9;
|
|---|
| 97 | IPPORT_SYSTAT =11;
|
|---|
| 98 | IPPORT_DAYTIME =13;
|
|---|
| 99 | IPPORT_NETSTAT =15;
|
|---|
| 100 | IPPORT_FTP =21;
|
|---|
| 101 | IPPORT_TELNET =23;
|
|---|
| 102 | IPPORT_SMTP =25;
|
|---|
| 103 | IPPORT_TIMESERVER =37;
|
|---|
| 104 | IPPORT_NAMESERVER =42;
|
|---|
| 105 | IPPORT_WHOIS =43;
|
|---|
| 106 | IPPORT_MTP =57;
|
|---|
| 107 | IPPORT_TFTP =69;
|
|---|
| 108 | IPPORT_RJE =77;
|
|---|
| 109 | IPPORT_FINGER =79;
|
|---|
| 110 | IPPORT_TTYLINK =87;
|
|---|
| 111 | IPPORT_SUPDUP =95;
|
|---|
| 112 | IPPORT_EXECSERVER =512;
|
|---|
| 113 | IPPORT_LOGINSERVER =513;
|
|---|
| 114 | IPPORT_CMDSERVER =514;
|
|---|
| 115 | IPPORT_EFSSERVER =520;
|
|---|
| 116 | IPPORT_BIFFUDP =512;
|
|---|
| 117 | IPPORT_WHOSERVER =513;
|
|---|
| 118 | IPPORT_ROUTESERVER =520;
|
|---|
| 119 | IPPORT_RESERVED =1024;
|
|---|
| 120 |
|
|---|
| 121 | IMPLINK_IP =155;
|
|---|
| 122 | IMPLINK_LOWEXPER =156;
|
|---|
| 123 | IMPLINK_HIGHEXPER =158;
|
|---|
| 124 |
|
|---|
| 125 | Type in_addr=Record
|
|---|
| 126 | Case Integer Of
|
|---|
| 127 | 1:(S_un_b:Record s_b1,s_b2,s_b3,s_b4:Byte; End;);
|
|---|
| 128 | 2:(s_un_w:Record s_w1,s_w2:Word; End;);
|
|---|
| 129 | 3:(s_addr:LongWord);
|
|---|
| 130 | End;
|
|---|
| 131 |
|
|---|
| 132 | Const
|
|---|
| 133 | IN_CLASSA_NET =$ff000000;
|
|---|
| 134 | IN_CLASSA_NSHIFT =24;
|
|---|
| 135 | IN_CLASSA_HOST =$00ffffff;
|
|---|
| 136 | IN_CLASSA_MAX =128;
|
|---|
| 137 |
|
|---|
| 138 | IN_CLASSB_NET =$ffff0000;
|
|---|
| 139 | IN_CLASSB_NSHIFT =16;
|
|---|
| 140 | IN_CLASSB_HOST =$0000ffff;
|
|---|
| 141 | IN_CLASSB_MAX =65536;
|
|---|
| 142 |
|
|---|
| 143 | IN_CLASSC_NET =$ffffff00;
|
|---|
| 144 | IN_CLASSC_NSHIFT =8;
|
|---|
| 145 | IN_CLASSC_HOST =$000000ff;
|
|---|
| 146 |
|
|---|
| 147 | INADDR_ANY =$00000000;
|
|---|
| 148 | INADDR_LOOPBACK =$7f000001;
|
|---|
| 149 | INADDR_BROADCAST =$ffffffff;
|
|---|
| 150 | INADDR_NONE =$ffffffff;
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 | Type
|
|---|
| 154 | sockaddr_in=Record
|
|---|
| 155 | sin_family:Integer;
|
|---|
| 156 | sin_port:Word;
|
|---|
| 157 | sin_addr:in_addr;
|
|---|
| 158 | sin_zero:CString[7];
|
|---|
| 159 | End;
|
|---|
| 160 |
|
|---|
| 161 | Const
|
|---|
| 162 | WSADESCRIPTION_LEN =256;
|
|---|
| 163 | WSASYS_STATUS_LEN =128;
|
|---|
| 164 |
|
|---|
| 165 | Type
|
|---|
| 166 | WSAData=Record
|
|---|
| 167 | wVersion:Word;
|
|---|
| 168 | wHighVersion:Word;
|
|---|
| 169 | szDescription: array[0..WSADESCRIPTION_LEN] of Char;
|
|---|
| 170 | szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
|
|---|
| 171 | iMaxSockets:Word;
|
|---|
| 172 | iMaxUdpDg:Word;
|
|---|
| 173 | lpVendorInfo:PChar;
|
|---|
| 174 | End;
|
|---|
| 175 | PWSADATA=^WSAData;
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | Const
|
|---|
| 179 | IP_OPTIONS =1;
|
|---|
| 180 |
|
|---|
| 181 | Const
|
|---|
| 182 | INVALID_SOCKET = -1;
|
|---|
| 183 | SOCKET_ERROR = -1;
|
|---|
| 184 |
|
|---|
| 185 | Const
|
|---|
| 186 | SOCK_STREAM =1; /* stream socket */
|
|---|
| 187 | SOCK_DGRAM =2; /* datagram socket */
|
|---|
| 188 | SOCK_RAW =3; /* raw-protocol interface */
|
|---|
| 189 | SOCK_RDM =4; /* reliably-delivered message */
|
|---|
| 190 | SOCK_SEQPACKET =5; /* sequenced packet stream */
|
|---|
| 191 |
|
|---|
| 192 | Const
|
|---|
| 193 | SO_DEBUG =$0001; /* turn on debugging info recording */
|
|---|
| 194 | SO_ACCEPTCONN =$0002; /* socket has had listen() */
|
|---|
| 195 | SO_REUSEADDR =$0004; /* allow local address reuse */
|
|---|
| 196 | SO_KEEPALIVE =$0008; /* keep connections alive */
|
|---|
| 197 | SO_DONTROUTE =$0010; /* just use interface addresses */
|
|---|
| 198 | SO_BROADCAST =$0020; /* permit sending of broadcast msgs */
|
|---|
| 199 | SO_USELOOPBACK =$0040; /* bypass hardware when possible */
|
|---|
| 200 | SO_LINGER =$0080; /* linger on close if data present */
|
|---|
| 201 | SO_OOBINLINE =$0100; /* leave received OOB data in line */
|
|---|
| 202 | SO_DONTLINGER =NOT SO_LINGER; /* dont linger */
|
|---|
| 203 | SO_SNDBUF =$1001; /* send buffer size */
|
|---|
| 204 | SO_RCVBUF =$1002; /* receive buffer size */
|
|---|
| 205 | SO_SNDLOWAT =$1003; /* send low-water mark */
|
|---|
| 206 | SO_RCVLOWAT =$1004; /* receive low-water mark */
|
|---|
| 207 | SO_SNDTIMEO =$1005; /* send timeout */
|
|---|
| 208 | SO_RCVTIMEO =$1006; /* receive timeout */
|
|---|
| 209 | SO_ERROR =$1007; /* get error status and clear */
|
|---|
| 210 | SO_TYPE =$1008; /* get socket type */
|
|---|
| 211 |
|
|---|
| 212 | Const
|
|---|
| 213 | TCP_NODELAY =$0001;
|
|---|
| 214 |
|
|---|
| 215 | Const
|
|---|
| 216 | AF_UNSPEC =0; /* unspecified */
|
|---|
| 217 | AF_UNIX =1; /* local to host (pipes, portals) */
|
|---|
| 218 | AF_INET =2; /* internetwork: UDP, TCP, etc. */
|
|---|
| 219 | AF_IMPLINK =3; /* arpanet imp addresses */
|
|---|
| 220 | AF_PUP =4; /* pup protocols: e.g. BSP */
|
|---|
| 221 | AF_CHAOS =5; /* mit CHAOS protocols */
|
|---|
| 222 | AF_NS =6; /* XEROX NS protocols */
|
|---|
| 223 | AF_ISO =7; /* ISO protocols */
|
|---|
| 224 | AF_OSI =AF_ISO; /* OSI is ISO */
|
|---|
| 225 | AF_ECMA =8; /* european computer manufacturers */
|
|---|
| 226 | AF_DATAKIT =9; /* datakit protocols */
|
|---|
| 227 | AF_CCITT =10; /* CCITT protocols, X.25 etc */
|
|---|
| 228 | AF_SNA =11; /* IBM SNA */
|
|---|
| 229 | AF_DECnet =12; /* DECnet */
|
|---|
| 230 | AF_DLI =13; /* Direct data link interface */
|
|---|
| 231 | AF_LAT =14; /* LAT */
|
|---|
| 232 | AF_HYLINK =15; /* NSC Hyperchannel */
|
|---|
| 233 | AF_APPLETALK =16; /* AppleTalk */
|
|---|
| 234 | AF_NETBIOS =17; /* NetBios-style addresses */
|
|---|
| 235 | AF_MAX =18;
|
|---|
| 236 |
|
|---|
| 237 | Type
|
|---|
| 238 | sockaddr=Record
|
|---|
| 239 | sa_family:Word;
|
|---|
| 240 | sa_data:CString[13];
|
|---|
| 241 | End;
|
|---|
| 242 |
|
|---|
| 243 | sockproto=Record
|
|---|
| 244 | sp_family:Word;
|
|---|
| 245 | sp_protocol:Word;
|
|---|
| 246 | End;
|
|---|
| 247 |
|
|---|
| 248 | Const
|
|---|
| 249 | PF_UNSPEC =AF_UNSPEC;
|
|---|
| 250 | PF_UNIX =AF_UNIX;
|
|---|
| 251 | PF_INET =AF_INET;
|
|---|
| 252 | PF_IMPLINK =AF_IMPLINK;
|
|---|
| 253 | PF_PUP =AF_PUP;
|
|---|
| 254 | PF_CHAOS =AF_CHAOS;
|
|---|
| 255 | PF_NS =AF_NS;
|
|---|
| 256 | PF_ISO =AF_ISO;
|
|---|
| 257 | PF_OSI =AF_OSI;
|
|---|
| 258 | PF_ECMA =AF_ECMA;
|
|---|
| 259 | PF_DATAKIT =AF_DATAKIT;
|
|---|
| 260 | PF_CCITT =AF_CCITT;
|
|---|
| 261 | PF_SNA =AF_SNA;
|
|---|
| 262 | PF_DECnet =AF_DECnet;
|
|---|
| 263 | PF_DLI =AF_DLI;
|
|---|
| 264 | PF_LAT =AF_LAT;
|
|---|
| 265 | PF_HYLINK =AF_HYLINK;
|
|---|
| 266 | PF_APPLETALK =AF_APPLETALK;
|
|---|
| 267 | PF_MAX =AF_MAX;
|
|---|
| 268 |
|
|---|
| 269 | Type
|
|---|
| 270 | linger=Record
|
|---|
| 271 | l_onoff:LongInt;
|
|---|
| 272 | l_linger:LongInt;
|
|---|
| 273 | End;
|
|---|
| 274 |
|
|---|
| 275 | Const
|
|---|
| 276 | SOL_SOCKET =$ffff; /* options for socket level */
|
|---|
| 277 |
|
|---|
| 278 | SOMAXCONN =5;
|
|---|
| 279 |
|
|---|
| 280 | MSG_OOB =1; /* process out-of-band data */
|
|---|
| 281 | MSG_PEEK =2; /* peek at incoming message */
|
|---|
| 282 | MSG_DONTROUTE =4; /* send without using routing tables */
|
|---|
| 283 | MSG_MAXIOVLEN =16;
|
|---|
| 284 |
|
|---|
| 285 | MAXGETHOSTSTRUCT =1024;
|
|---|
| 286 |
|
|---|
| 287 | FD_READ =$01;
|
|---|
| 288 | FD_WRITE =$02;
|
|---|
| 289 | FD_OOB =$04;
|
|---|
| 290 | FD_ACCEPT =$08;
|
|---|
| 291 | FD_CONNECT =$10;
|
|---|
| 292 | FD_CLOSE =$20;
|
|---|
| 293 |
|
|---|
| 294 | WSABASEERR =10000;
|
|---|
| 295 | WSAEINTR =(WSABASEERR+4);
|
|---|
| 296 | WSAEBADF =(WSABASEERR+9);
|
|---|
| 297 | WSAEACCES =(WSABASEERR+13);
|
|---|
| 298 | WSAEFAULT =(WSABASEERR+14);
|
|---|
| 299 | WSAEINVAL =(WSABASEERR+22);
|
|---|
| 300 | WSAEMFILE =(WSABASEERR+24);
|
|---|
| 301 | WSAEWOULDBLOCK =(WSABASEERR+35);
|
|---|
| 302 | WSAEINPROGRESS =(WSABASEERR+36);
|
|---|
| 303 | WSAEALREADY =(WSABASEERR+37);
|
|---|
| 304 | WSAENOTSOCK =(WSABASEERR+38);
|
|---|
| 305 | WSAEDESTADDRREQ =(WSABASEERR+39);
|
|---|
| 306 | WSAEMSGSIZE =(WSABASEERR+40);
|
|---|
| 307 | WSAEPROTOTYPE =(WSABASEERR+41);
|
|---|
| 308 | WSAENOPROTOOPT =(WSABASEERR+42);
|
|---|
| 309 | WSAEPROTONOSUPPORT =(WSABASEERR+43);
|
|---|
| 310 | WSAESOCKTNOSUPPORT =(WSABASEERR+44);
|
|---|
| 311 | WSAEOPNOTSUPP =(WSABASEERR+45);
|
|---|
| 312 | WSAEPFNOSUPPORT =(WSABASEERR+46);
|
|---|
| 313 | WSAEAFNOSUPPORT =(WSABASEERR+47);
|
|---|
| 314 | WSAEADDRINUSE =(WSABASEERR+48);
|
|---|
| 315 | WSAEADDRNOTAVAIL =(WSABASEERR+49);
|
|---|
| 316 | WSAENETDOWN =(WSABASEERR+50);
|
|---|
| 317 | WSAENETUNREACH =(WSABASEERR+51);
|
|---|
| 318 | WSAENETRESET =(WSABASEERR+52);
|
|---|
| 319 | WSAECONNABORTED =(WSABASEERR+53);
|
|---|
| 320 | WSAECONNRESET =(WSABASEERR+54);
|
|---|
| 321 | WSAENOBUFS =(WSABASEERR+55);
|
|---|
| 322 | WSAEISCONN =(WSABASEERR+56);
|
|---|
| 323 | WSAENOTCONN =(WSABASEERR+57);
|
|---|
| 324 | WSAESHUTDOWN =(WSABASEERR+58);
|
|---|
| 325 | WSAETOOMANYREFS =(WSABASEERR+59);
|
|---|
| 326 | WSAETIMEDOUT =(WSABASEERR+60);
|
|---|
| 327 | WSAECONNREFUSED =(WSABASEERR+61);
|
|---|
| 328 | WSAELOOP =(WSABASEERR+62);
|
|---|
| 329 | WSAENAMETOOLONG =(WSABASEERR+63);
|
|---|
| 330 | WSAEHOSTDOWN =(WSABASEERR+64);
|
|---|
| 331 | WSAEHOSTUNREACH =(WSABASEERR+65);
|
|---|
| 332 | WSAENOTEMPTY =(WSABASEERR+66);
|
|---|
| 333 | WSAEPROCLIM =(WSABASEERR+67);
|
|---|
| 334 | WSAEUSERS =(WSABASEERR+68);
|
|---|
| 335 | WSAEDQUOT =(WSABASEERR+69);
|
|---|
| 336 | WSAESTALE =(WSABASEERR+70);
|
|---|
| 337 | WSAEREMOTE =(WSABASEERR+71);
|
|---|
| 338 | WSASYSNOTREADY =(WSABASEERR+91);
|
|---|
| 339 | WSAVERNOTSUPPORTED =(WSABASEERR+92);
|
|---|
| 340 | WSANOTINITIALISED =(WSABASEERR+93);
|
|---|
| 341 | WSAHOST_NOT_FOUND =(WSABASEERR+1001);
|
|---|
| 342 | HOST_NOT_FOUND =WSAHOST_NOT_FOUND;
|
|---|
| 343 | WSATRY_AGAIN =(WSABASEERR+1002);
|
|---|
| 344 | TRY_AGAIN =WSATRY_AGAIN;
|
|---|
| 345 | WSANO_RECOVERY =(WSABASEERR+1003);
|
|---|
| 346 | NO_RECOVERY =WSANO_RECOVERY;
|
|---|
| 347 | WSANO_DATA =(WSABASEERR+1004);
|
|---|
| 348 | NO_DATA =WSANO_DATA;
|
|---|
| 349 | WSANO_ADDRESS =WSANO_DATA;
|
|---|
| 350 | NO_ADDRESS =WSANO_ADDRESS;
|
|---|
| 351 |
|
|---|
| 352 | Const
|
|---|
| 353 | EWOULDBLOCK =WSAEWOULDBLOCK;
|
|---|
| 354 | EINPROGRESS =WSAEINPROGRESS;
|
|---|
| 355 | EALREADY =WSAEALREADY;
|
|---|
| 356 | ENOTSOCK =WSAENOTSOCK;
|
|---|
| 357 | EDESTADDRREQ =WSAEDESTADDRREQ;
|
|---|
| 358 | EMSGSIZE =WSAEMSGSIZE;
|
|---|
| 359 | EPROTOTYPE =WSAEPROTOTYPE;
|
|---|
| 360 | ENOPROTOOPT =WSAENOPROTOOPT;
|
|---|
| 361 | EPROTONOSUPPORT =WSAEPROTONOSUPPORT;
|
|---|
| 362 | ESOCKTNOSUPPORT =WSAESOCKTNOSUPPORT;
|
|---|
| 363 | EOPNOTSUPP =WSAEOPNOTSUPP;
|
|---|
| 364 | EPFNOSUPPORT =WSAEPFNOSUPPORT;
|
|---|
| 365 | EAFNOSUPPORT =WSAEAFNOSUPPORT;
|
|---|
| 366 | EADDRINUSE =WSAEADDRINUSE;
|
|---|
| 367 | EADDRNOTAVAIL =WSAEADDRNOTAVAIL;
|
|---|
| 368 | ENETDOWN =WSAENETDOWN;
|
|---|
| 369 | ENETUNREACH =WSAENETUNREACH;
|
|---|
| 370 | ENETRESET =WSAENETRESET;
|
|---|
| 371 | ECONNABORTED =WSAECONNABORTED;
|
|---|
| 372 | ECONNRESET =WSAECONNRESET;
|
|---|
| 373 | ENOBUFS =WSAENOBUFS;
|
|---|
| 374 | EISCONN =WSAEISCONN;
|
|---|
| 375 | ENOTCONN =WSAENOTCONN;
|
|---|
| 376 | ESHUTDOWN =WSAESHUTDOWN;
|
|---|
| 377 | ETOOMANYREFS =WSAETOOMANYREFS;
|
|---|
| 378 | ETIMEDOUT =WSAETIMEDOUT;
|
|---|
| 379 | ECONNREFUSED =WSAECONNREFUSED;
|
|---|
| 380 | ELOOP =WSAELOOP;
|
|---|
| 381 | ENAMETOOLONG =WSAENAMETOOLONG;
|
|---|
| 382 | EHOSTDOWN =WSAEHOSTDOWN;
|
|---|
| 383 | EHOSTUNREACH =WSAEHOSTUNREACH;
|
|---|
| 384 | ENOTEMPTY =WSAENOTEMPTY;
|
|---|
| 385 | EPROCLIM =WSAEPROCLIM;
|
|---|
| 386 | EUSERS =WSAEUSERS;
|
|---|
| 387 | EDQUOT =WSAEDQUOT;
|
|---|
| 388 | ESTALE =WSAESTALE;
|
|---|
| 389 | EREMOTE =WSAEREMOTE;
|
|---|
| 390 |
|
|---|
| 391 | Imports
|
|---|
| 392 | Function __WSAFDIsSet(s:TSOCKET;Var fd:TFDSET):LongInt; ApiEntry; 'PMWSock' name '__WSAFDIsSet';
|
|---|
| 393 | Function accept(s:TSOCKET;Var addr;Var addrlen:LongInt):TSOCKET; ApiEntry; 'PMWSock' name 'accept';
|
|---|
| 394 | Function bind(s:TSOCKET;Const addr;namelen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'bind';
|
|---|
| 395 | Function closesocket(s:TSOCKET):LongInt; ApiEntry; 'PMWSock' name 'closesocket';
|
|---|
| 396 | Function connect(s:TSOCKET;Const name;namelen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'connect';
|
|---|
| 397 | Function ioctlsocket(s:TSOCKET;cmd:LongInt;Var argp:LongWord):LongInt; ApiEntry; 'PMWSock' name 'ioctlsocket';
|
|---|
| 398 | Function getpeername(s:TSOCKET;Var name;Var nameLen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'getpeername';
|
|---|
| 399 | Function getsockname(s:TSOCKET;Var name;Var namelen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'getsockname';
|
|---|
| 400 | Function getsockopt(s:TSOCKET;level,optname:LongInt;Var optval;Var optlen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'getsockopt';
|
|---|
| 401 | Function htonl(hostlong:LongWord):LongWord; ApiEntry; 'PMWSock' name 'htonl';
|
|---|
| 402 | Function htons(hostshort:Word):Word; ApiEntry; 'PMWSock' name 'htons';
|
|---|
| 403 | Function inet_addr(Const cp:CString):LongWord; ApiEntry; 'PMWSock' name 'inet_addr';
|
|---|
| 404 | Function inet_ntoa(Var _in):PChar; ApiEntry; 'PMWSock' name 'inet_ntoa';
|
|---|
| 405 | Function listen(s:TSOCKET;backlog:LongInt):LongInt; ApiEntry; 'PMWSock' name 'listen';
|
|---|
| 406 | Function ntohl(netlong:LongWord):LongWord; ApiEntry; 'PMWSock' name 'ntohl';
|
|---|
| 407 | Function ntohs(netshort:Word):Word; ApiEntry; 'PMWSock' name 'ntohs';
|
|---|
| 408 | Function recv(s:TSOCKET;Var Buf;len,flags:LongInt):LongInt; ApiEntry; 'PMWSock' name 'recv';
|
|---|
| 409 | Function recvfrom(s:TSOCKET;Var Buf;len,flags:LongInt;
|
|---|
| 410 | Var from:sockaddr;Var fromLen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'recvfrom';
|
|---|
| 411 | Function select(nfds:LongInt;Var readfds,writefds,exceptfds:TFDSET;
|
|---|
| 412 | Const timeout:timeval):LongInt; ApiEntry; 'PMWSock' name 'select';
|
|---|
| 413 | Function send(s:TSOCKET;Const Buf;len,flags:LongInt):LongInt; ApiEntry; 'PMWSock' name 'send';
|
|---|
| 414 | Function sendto(s:TSOCKET;Const Buf;len,flags:LongInt;
|
|---|
| 415 | Const _to:sockaddr;tolen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'sendto';
|
|---|
| 416 | Function setsockopt(s:TSOCKET;level,optname:LongInt;
|
|---|
| 417 | Const optval;optlen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'setsockopt';
|
|---|
| 418 | Function shutdown(s:TSOCKET;how:LongInt):LongInt; ApiEntry; 'PMWSock' name 'shutdown';
|
|---|
| 419 | Function socket(af,typ,protocol:LongInt):TSOCKET; ApiEntry; 'PMWSock' name 'socket';
|
|---|
| 420 | Function gethostbyaddr(Var addr;len,typ:LongInt):phostent; ApiEntry; 'PMWSock' name 'gethostbyaddr';
|
|---|
| 421 | Function gethostbyname(Const name:CString):phostent; ApiEntry; 'PMWSock' name 'gethostbyname';
|
|---|
| 422 | Function gethostname(Const name:CString;namelen:LongInt):LongInt; ApiEntry; 'PMWSock' name 'gethostname';
|
|---|
| 423 | Function getservbyport(port:LongInt;Const proto:CString):pservent; ApiEntry; 'PMWSock' name 'getservbyport';
|
|---|
| 424 | Function getservbyname(Const name,proto:CString):pservent; ApiEntry; 'PMWSock' name 'getservbyname';
|
|---|
| 425 | Function getprotobynumber(proto:LongInt):pprotoent; ApiEntry; 'PMWSock' name 'getprotobynumber';
|
|---|
| 426 | Function getprotobyname(Const name:CString):pprotoent; ApiEntry; 'PMWSock' name 'getprotobyname';
|
|---|
| 427 | Function WSAStartup(wVersionRequired:Word;Var aWSAData:WSAData):LongInt; ApiEntry; 'PMWSock' name 'WSAStartup';
|
|---|
| 428 | Function WSACleanup:LongInt; ApiEntry; 'PMWSock' name 'WSACleanup';
|
|---|
| 429 | Procedure WSASetLastError(iError:LongInt); ApiEntry; 'PMWSock' name 'WSASetLastError';
|
|---|
| 430 | Function WSAGetLastError:LongInt; ApiEntry; 'PMWSock' name 'WSAGetLastError';
|
|---|
| 431 | Function WSAIsBlocking:LongBool; ApiEntry; 'PMWSock' name 'WSAIsBlocking';
|
|---|
| 432 | Function WSAUnhookBlockingHook:LongInt; ApiEntry; 'PMWSock' name 'WSAUnhookBlockingHook';
|
|---|
| 433 | Function WSASetBlockingHook(lpBlockFunc:Pointer):Pointer; ApiEntry; 'PMWSock' name 'WSASetBlockingHook';
|
|---|
| 434 | Function WSACancelBlockingCall:LongInt; ApiEntry; 'PMWSock' name 'WSACancelBlockingCall';
|
|---|
| 435 | Function WSAAsyncGetServByName(ahWnd:HWND;wMsg:LongWord;
|
|---|
| 436 | Const name,proto:CString;
|
|---|
| 437 | Var Buf;buflen:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncGetServByName';
|
|---|
| 438 | Function WSAAsyncGetServByPort(ahWnd:HWND;wMsg:LongWord;
|
|---|
| 439 | port:LongInt;Const proto:CString;
|
|---|
| 440 | Var Buf;buflen:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncGetServByPort';
|
|---|
| 441 | Function WSAAsyncGetProtoByName(ahWnd:HWND;wMsg:LongWord;
|
|---|
| 442 | Const name:CString;
|
|---|
| 443 | Var Buf;buflen:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncGetProtoByName';
|
|---|
| 444 | Function WSAAsyncGetProtoByNumber(ahWnd:HWND;wMsg:LongWord;
|
|---|
| 445 | number:LongInt;
|
|---|
| 446 | Var Buf;buflen:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncGetProtoByNumber';
|
|---|
| 447 | Function WSAAsyncGetHostByName(ahWnd:HWND;wMsg:LongWord;
|
|---|
| 448 | Const name:CString;
|
|---|
| 449 | Var Buf;buflen:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncGetHostByName';
|
|---|
| 450 | Function WSAAsyncGetHostByAddr(ahWnd:HWND;wMsg:LongWord;
|
|---|
| 451 | Const addr:CString;len,typ:LongInt;
|
|---|
| 452 | Var Buf;buflen:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncGetHostByAddr';
|
|---|
| 453 | Function WSACancelAsyncRequest(hAsyncTaskHandle:LongWord):LongInt; ApiEntry; 'PMWSock' name 'WSACancelAsyncRequest';
|
|---|
| 454 | Function WSAAsyncSelect(s:TSOCKET;ahWnd:HWND;wMsg:LongWord;lEvent:LongInt):LongWord; ApiEntry; 'PMWSock' name 'WSAAsyncSelect';
|
|---|
| 455 | End;
|
|---|
| 456 |
|
|---|
| 457 | /*
|
|---|
| 458 | #define FD_CLR(fd, set) do { \
|
|---|
| 459 | u_int __i; \
|
|---|
| 460 | for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) { \
|
|---|
| 461 | if (((fd_set *)(set))->fd_array[__i] == fd) { \
|
|---|
| 462 | while (__i < ((fd_set *)(set))->fd_count-1) { \
|
|---|
| 463 | ((fd_set *)(set))->fd_array[__i] = \
|
|---|
| 464 | ((fd_set *)(set))->fd_array[__i+1]; \
|
|---|
| 465 | __i++; \
|
|---|
| 466 | } \
|
|---|
| 467 | ((fd_set *)(set))->fd_count--; \
|
|---|
| 468 | break; \
|
|---|
| 469 | } \
|
|---|
| 470 | } \
|
|---|
| 471 | } while(0)
|
|---|
| 472 |
|
|---|
| 473 | #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)fd, (fd_set *)set)
|
|---|
| 474 |
|
|---|
| 475 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
|---|
| 476 | #define timercmp(tvp, uvp, cmp) \
|
|---|
| 477 | ((tvp)->tv_sec cmp (uvp)->tv_sec || \
|
|---|
| 478 | (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
|
|---|
| 479 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
|---|
| 480 |
|
|---|
| 481 | #define _IO(x,y) (IOC_VOID|(x<<8)|y)
|
|---|
| 482 |
|
|---|
| 483 | #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
|
|---|
| 484 |
|
|---|
| 485 | #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
|
|---|
| 486 | */
|
|---|
| 487 | {
|
|---|
| 488 |
|
|---|
| 489 | #define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
|
|---|
| 490 | #define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
|
|---|
| 491 | #define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
|
|---|
| 492 |
|
|---|
| 493 | /* Socket I/O Controls */
|
|---|
| 494 | #define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
|
|---|
| 495 | #define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
|
|---|
| 496 | #define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
|
|---|
| 497 | #define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
|
|---|
| 498 | #define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
|
|---|
| 499 |
|
|---|
| 500 | #define IN_CLASSA(i) (((long)(i) & $80000000) == 0)
|
|---|
| 501 | #define IN_CLASSB(i) (((long)(i) & $c0000000) == $80000000)
|
|---|
| 502 | #define IN_CLASSC(i) (((long)(i) & $e0000000) == $c0000000)
|
|---|
| 503 |
|
|---|
| 504 | #define h_errno WSAGetLastError()
|
|---|
| 505 |
|
|---|
| 506 | #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
|
|---|
| 507 | /*
|
|---|
| 508 | * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
|
|---|
| 509 | * when constructing the response to WSAAsyncSelect().
|
|---|
| 510 | */
|
|---|
| 511 | #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
|---|
| 512 | /*
|
|---|
| 513 | * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
|
|---|
| 514 | * to extract the buffer length from the lParam in the response
|
|---|
| 515 | * to a WSAGetXByY().
|
|---|
| 516 | */
|
|---|
| 517 | #define WSAGETASYNCBUFLEN(lParam) LOUSHORT(lParam)
|
|---|
| 518 | /*
|
|---|
| 519 | * WSAGETASYNCERROR is intended for use by the Windows Sockets application
|
|---|
| 520 | * to extract the error code from the lParam in the response
|
|---|
| 521 | * to a WSAGetXByY().
|
|---|
| 522 | */
|
|---|
| 523 | #define WSAGETASYNCERROR(lParam) HIUSHORT(lParam)
|
|---|
| 524 | /*
|
|---|
| 525 | * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
|
|---|
| 526 | * to extract the event code from the lParam in the response
|
|---|
| 527 | * to a WSAAsyncSelect().
|
|---|
| 528 | */
|
|---|
| 529 | #define WSAGETSELECTEVENT(lParam) LOUSHORT(lParam)
|
|---|
| 530 | /*
|
|---|
| 531 | * WSAGETSELECTERROR is intended for use by the Windows Sockets application
|
|---|
| 532 | * to extract the error code from the lParam in the response
|
|---|
| 533 | * to a WSAAsyncSelect().
|
|---|
| 534 | */
|
|---|
| 535 | #define WSAGETSELECTERROR(lParam) HIUSHORT(lParam)
|
|---|
| 536 |
|
|---|
| 537 | #endif /* _WINSOCKAPI_ */
|
|---|
| 538 | }
|
|---|
| 539 |
|
|---|
| 540 | Procedure FD_ZERO(Var aset:TFDSET);
|
|---|
| 541 | Procedure FD_SET(Socket: TSocket; Var FDSet: TFDSet);
|
|---|
| 542 |
|
|---|
| 543 | implementation
|
|---|
| 544 |
|
|---|
| 545 | Procedure FD_ZERO(Var aset:TFDSET);
|
|---|
| 546 | Begin
|
|---|
| 547 | aset.fd_count:=0;
|
|---|
| 548 | End;
|
|---|
| 549 |
|
|---|
| 550 | procedure FD_SET(Socket: TSocket; var FDSet: TFDSet);
|
|---|
| 551 | begin
|
|---|
| 552 | if FDSet.fd_count < FD_SETSIZE then
|
|---|
| 553 | begin
|
|---|
| 554 | FDSet.fd_array[FDSet.fd_count] := Socket;
|
|---|
| 555 | Inc(FDSet.fd_count);
|
|---|
| 556 | end;
|
|---|
| 557 | end;
|
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 | end.
|
|---|