3 Definitions for winsock 1.1
5 Portions Copyright (c) 1980, 1983, 1988, 1993
6 The Regents of the University of California. All rights reserved.
8 Portions Copyright (c) 1993 by Digital Equipment Corporation.
13 #define _GNU_H_WINDOWS32_SOCKETS
20 #if !defined ( _BSDTYPES_DEFINED )
21 /* also defined in gmon.h and in cygwin's sys/types */
22 typedef unsigned char u_char
;
23 typedef unsigned short u_short
;
24 typedef unsigned int u_int
;
25 typedef unsigned long u_long
;
26 #define _BSDTYPES_DEFINED
27 #endif /* !defined _BSDTYPES_DEFINED */
33 /* shutdown() how types */
34 #define SD_RECEIVE 0x00
38 #ifndef _SYS_TYPES_FD_SET
39 /* fd_set may have be defined by the newlib <sys/types.h>
40 * if __USE_W32_SOCKETS not defined.
45 typedef struct fd_set
{
47 SOCKET fd_array
[FD_SETSIZE
];
49 int PASCAL
__WSAFDIsSet(SOCKET
,fd_set
*);
51 #define FD_CLR(fd,set) do { u_int __i;\
52 for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) {\
53 if (((fd_set *)(set))->fd_array[__i] == (fd)) {\
54 while (__i < ((fd_set *)(set))->fd_count-1) {\
55 ((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i+1];\
58 ((fd_set*)(set))->fd_count--;\
65 #define FD_SET(fd, set) do { \
66 if (((fd_set *)(set))->fd_count < FD_SETSIZE) \
67 ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=(fd);\
71 #define FD_ZERO(set) (((fd_set *)(set))->fd_count=0)
74 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
76 #elif !defined(USE_SYS_TYPES_FD_SET)
77 #warning "fd_set and associated macros have been defined in sys/types. \
78 This can cause runtime problems with W32 sockets"
79 #endif /* ndef _SYS_TYPES_FD_SET */
81 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
92 #define h_addr h_addr_list[0]
98 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
99 #define timercmp(tvp, uvp, cmp) \
100 (((tvp)->tv_sec != (uvp)->tv_sec) ? \
101 ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
102 ((tvp)->tv_usec cmp (uvp)->tv_usec))
103 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
104 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
105 #define IOCPARM_MASK 0x7f
106 #define IOC_VOID 0x20000000
107 #define IOC_OUT 0x40000000
108 #define IOC_IN 0x80000000
109 #define IOC_INOUT (IOC_IN|IOC_OUT)
111 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
112 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
113 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
114 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
115 #define FIONBIO _IOW('f', 126, u_long)
116 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
118 #define FIONREAD _IOR('f', 127, u_long)
119 #define FIOASYNC _IOW('f', 125, u_long)
120 #define SIOCSHIWAT _IOW('s', 0, u_long)
121 #define SIOCGHIWAT _IOR('s', 1, u_long)
122 #define SIOCSLOWAT _IOW('s', 2, u_long)
123 #define SIOCGLOWAT _IOR('s', 3, u_long)
124 #define SIOCATMARK _IOR('s', 7, u_long)
126 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
144 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
147 #define IPPROTO_ICMP 1
148 #define IPPROTO_IGMP 2
149 #define IPPROTO_GGP 3
150 #define IPPROTO_TCP 6
151 #define IPPROTO_PUP 12
152 #define IPPROTO_UDP 17
153 #define IPPROTO_IDP 22
154 #define IPPROTO_ND 77
155 #define IPPROTO_RAW 255
156 #define IPPROTO_MAX 256
157 #define IPPORT_ECHO 7
158 #define IPPORT_DISCARD 9
159 #define IPPORT_SYSTAT 11
160 #define IPPORT_DAYTIME 13
161 #define IPPORT_NETSTAT 15
162 #define IPPORT_FTP 21
163 #define IPPORT_TELNET 23
164 #define IPPORT_SMTP 25
165 #define IPPORT_TIMESERVER 37
166 #define IPPORT_NAMESERVER 42
167 #define IPPORT_WHOIS 43
168 #define IPPORT_MTP 57
169 #define IPPORT_TFTP 69
170 #define IPPORT_RJE 77
171 #define IPPORT_FINGER 79
172 #define IPPORT_TTYLINK 87
173 #define IPPORT_SUPDUP 95
174 #define IPPORT_EXECSERVER 512
175 #define IPPORT_LOGINSERVER 513
176 #define IPPORT_CMDSERVER 514
177 #define IPPORT_EFSSERVER 520
178 #define IPPORT_BIFFUDP 512
179 #define IPPORT_WHOSERVER 513
180 #define IPPORT_ROUTESERVER 520
181 #define IPPORT_RESERVED 1024
182 #define IMPLINK_IP 155
183 #define IMPLINK_LOWEXPER 156
184 #define IMPLINK_HIGHEXPER 158
187 struct { u_char s_b1
,s_b2
,s_b3
,s_b4
; } S_un_b
;
188 struct { u_short s_w1
,s_w2
; } S_un_w
;
191 #define s_addr S_un.S_addr
192 #define s_host S_un.S_un_b.s_b2
193 #define s_net S_un.S_un_b.s_b1
194 #define s_imp S_un.S_un_w.s_w2
195 #define s_impno S_un.S_un_b.s_b4
196 #define s_lh S_un.S_un_b.s_b3
198 #define IN_CLASSA(i) ((long)(i)&0x80000000)
199 #define IN_CLASSA_NET 0xff000000
200 #define IN_CLASSA_NSHIFT 24
201 #define IN_CLASSA_HOST 0x00ffffff
202 #define IN_CLASSA_MAX 128
203 #define IN_CLASSB(i) (((long)(i)&0xc0000000)==0x80000000)
204 #define IN_CLASSB_NET 0xffff0000
205 #define IN_CLASSB_NSHIFT 16
206 #define IN_CLASSB_HOST 0x0000ffff
207 #define IN_CLASSB_MAX 65536
208 #define IN_CLASSC(i) (((long)(i)&0xe0000000)==0xc0000000)
209 #define IN_CLASSC_NET 0xffffff00
210 #define IN_CLASSC_NSHIFT 8
211 #define IN_CLASSC_HOST 0xff
212 #define INADDR_ANY (u_long)0
213 #define INADDR_LOOPBACK 0x7f000001
214 #define INADDR_BROADCAST (u_long)0xffffffff
215 #define INADDR_NONE 0xffffffff
219 struct in_addr sin_addr
;
222 #define WSADESCRIPTION_LEN 256
223 #define WSASYS_STATUS_LEN 128
224 typedef struct WSAData
{
227 char szDescription
[WSADESCRIPTION_LEN
+1];
228 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
229 unsigned short iMaxSockets
;
230 unsigned short iMaxUdpDg
;
233 typedef WSADATA
*LPWSADATA
;
235 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
238 #define SO_ACCEPTCONN 2
239 #define SO_REUSEADDR 4
240 #define SO_KEEPALIVE 8
241 #define SO_DONTROUTE 16
242 #define SO_BROADCAST 32
243 #define SO_USELOOPBACK 64
244 #define SO_LINGER 128
245 #define SO_OOBINLINE 256
246 #define SO_DONTLINGER (u_int)(~SO_LINGER)
247 #define SO_SNDBUF 0x1001
248 #define SO_RCVBUF 0x1002
249 #define SO_SNDLOWAT 0x1003
250 #define SO_RCVLOWAT 0x1004
251 #define SO_SNDTIMEO 0x1005
252 #define SO_RCVTIMEO 0x1006
253 #define SO_ERROR 0x1007
254 #define SO_TYPE 0x1008
255 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
257 * Note that the next 5 IP defines are specific to WinSock 1.1 (wsock32.dll).
258 * They will cause errors or unexpected results if used with the
259 * (gs)etsockopts exported from the WinSock 2 lib, ws2_32.dll. Refer ws2tcpip.h.
261 #define IP_MULTICAST_IF 2
262 #define IP_MULTICAST_TTL 3
263 #define IP_MULTICAST_LOOP 4
264 #define IP_ADD_MEMBERSHIP 5
265 #define IP_DROP_MEMBERSHIP 6
267 #define IP_DEFAULT_MULTICAST_TTL 1
268 #define IP_DEFAULT_MULTICAST_LOOP 1
269 #define IP_MAX_MEMBERSHIPS 20
271 struct in_addr imr_multiaddr
;
272 struct in_addr imr_interface
;
274 #define INVALID_SOCKET (SOCKET)(~0)
275 #define SOCKET_ERROR (-1)
276 #define SOCK_STREAM 1
280 #define SOCK_SEQPACKET 5
281 #define TCP_NODELAY 0x0001
291 #define AF_OSI AF_ISO
300 #define AF_APPLETALK 16
301 #define AF_NETBIOS 17
302 #define AF_VOICEVIEW 18
303 #define AF_FIREFOX 19
304 #define AF_UNKNOWN1 20
308 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
314 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
320 #define PF_UNSPEC AF_UNSPEC
321 #define PF_UNIX AF_UNIX
322 #define PF_INET AF_INET
323 #define PF_IMPLINK AF_IMPLINK
324 #define PF_PUP AF_PUP
325 #define PF_CHAOS AF_CHAOS
327 #define PF_IPX AF_IPX
328 #define PF_ISO AF_ISO
329 #define PF_OSI AF_OSI
330 #define PF_ECMA AF_ECMA
331 #define PF_DATAKIT AF_DATAKIT
332 #define PF_CCITT AF_CCITT
333 #define PF_SNA AF_SNA
334 #define PF_DECnet AF_DECnet
335 #define PF_DLI AF_DLI
336 #define PF_LAT AF_LAT
337 #define PF_HYLINK AF_HYLINK
338 #define PF_APPLETALK AF_APPLETALK
339 #define PF_VOICEVIEW AF_VOICEVIEW
340 #define PF_FIREFOX AF_FIREFOX
341 #define PF_UNKNOWN1 AF_UNKNOWN1
342 #define PF_BAN AF_BAN
343 #define PF_ATM AF_ATM
344 #define PF_INET6 AF_INET6
345 #define PF_MAX AF_MAX
346 #define SOL_SOCKET 0xffff
348 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
351 #define MSG_DONTROUTE 4
352 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
353 #define MSG_MAXIOVLEN 16
354 #define MSG_PARTIAL 0x8000
355 #define MAXGETHOSTSTRUCT 1024
360 #define FD_CONNECT 16
362 #define WSABASEERR 10000
363 #define WSAEINTR (WSABASEERR+4)
364 #define WSAEBADF (WSABASEERR+9)
365 #define WSAEACCES (WSABASEERR+13)
366 #define WSAEFAULT (WSABASEERR+14)
367 #define WSAEINVAL (WSABASEERR+22)
368 #define WSAEMFILE (WSABASEERR+24)
369 #define WSAEWOULDBLOCK (WSABASEERR+35)
370 #define WSAEINPROGRESS (WSABASEERR+36)
371 #define WSAEALREADY (WSABASEERR+37)
372 #define WSAENOTSOCK (WSABASEERR+38)
373 #define WSAEDESTADDRREQ (WSABASEERR+39)
374 #define WSAEMSGSIZE (WSABASEERR+40)
375 #define WSAEPROTOTYPE (WSABASEERR+41)
376 #define WSAENOPROTOOPT (WSABASEERR+42)
377 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
378 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
379 #define WSAEOPNOTSUPP (WSABASEERR+45)
380 #define WSAEPFNOSUPPORT (WSABASEERR+46)
381 #define WSAEAFNOSUPPORT (WSABASEERR+47)
382 #define WSAEADDRINUSE (WSABASEERR+48)
383 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
384 #define WSAENETDOWN (WSABASEERR+50)
385 #define WSAENETUNREACH (WSABASEERR+51)
386 #define WSAENETRESET (WSABASEERR+52)
387 #define WSAECONNABORTED (WSABASEERR+53)
388 #define WSAECONNRESET (WSABASEERR+54)
389 #define WSAENOBUFS (WSABASEERR+55)
390 #define WSAEISCONN (WSABASEERR+56)
391 #define WSAENOTCONN (WSABASEERR+57)
392 #define WSAESHUTDOWN (WSABASEERR+58)
393 #define WSAETOOMANYREFS (WSABASEERR+59)
394 #define WSAETIMEDOUT (WSABASEERR+60)
395 #define WSAECONNREFUSED (WSABASEERR+61)
396 #define WSAELOOP (WSABASEERR+62)
397 #define WSAENAMETOOLONG (WSABASEERR+63)
398 #define WSAEHOSTDOWN (WSABASEERR+64)
399 #define WSAEHOSTUNREACH (WSABASEERR+65)
400 #define WSAENOTEMPTY (WSABASEERR+66)
401 #define WSAEPROCLIM (WSABASEERR+67)
402 #define WSAEUSERS (WSABASEERR+68)
403 #define WSAEDQUOT (WSABASEERR+69)
404 #define WSAESTALE (WSABASEERR+70)
405 #define WSAEREMOTE (WSABASEERR+71)
406 #define WSAEDISCON (WSABASEERR+101)
407 #define WSASYSNOTREADY (WSABASEERR+91)
408 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
409 #define WSANOTINITIALISED (WSABASEERR+93)
410 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
411 #define WSATRY_AGAIN (WSABASEERR+1002)
412 #define WSANO_RECOVERY (WSABASEERR+1003)
413 #define WSANO_DATA (WSABASEERR+1004)
414 #define WSANO_ADDRESS WSANO_DATA
415 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
416 #define h_errno WSAGetLastError()
417 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
418 #define TRY_AGAIN WSATRY_AGAIN
419 #define NO_RECOVERY WSANO_RECOVERY
420 #define NO_DATA WSANO_DATA
421 #define NO_ADDRESS WSANO_ADDRESS
422 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
423 SOCKET PASCAL
accept(SOCKET
,struct sockaddr
*,int*);
424 int PASCAL
bind(SOCKET
,const struct sockaddr
*,int);
425 int PASCAL
closesocket(SOCKET
);
426 int PASCAL
connect(SOCKET
,const struct sockaddr
*,int);
427 int PASCAL
ioctlsocket(SOCKET
,long,u_long
*);
428 int PASCAL
getpeername(SOCKET
,struct sockaddr
*,int*);
429 int PASCAL
getsockname(SOCKET
,struct sockaddr
*,int*);
430 int PASCAL
getsockopt(SOCKET
,int,int,char*,int*);
431 unsigned long PASCAL
inet_addr(const char*);
432 DECLARE_STDCALL_P(char *) inet_ntoa(struct in_addr
);
433 int PASCAL
listen(SOCKET
,int);
434 int PASCAL
recv(SOCKET
,char*,int,int);
435 int PASCAL
recvfrom(SOCKET
,char*,int,int,struct sockaddr
*,int*);
436 int PASCAL
send(SOCKET
,const char*,int,int);
437 int PASCAL
sendto(SOCKET
,const char*,int,int,const struct sockaddr
*,int);
438 int PASCAL
setsockopt(SOCKET
,int,int,const char*,int);
439 int PASCAL
shutdown(SOCKET
,int);
440 SOCKET PASCAL
socket(int,int,int);
441 DECLARE_STDCALL_P(struct hostent
*) gethostbyaddr(const char*,int,int);
442 DECLARE_STDCALL_P(struct hostent
*) gethostbyname(const char*);
443 DECLARE_STDCALL_P(struct servent
*) getservbyport(int,const char*);
444 DECLARE_STDCALL_P(struct servent
*) getservbyname(const char*,const char*);
445 DECLARE_STDCALL_P(struct protoent
*) getprotobynumber(int);
446 DECLARE_STDCALL_P(struct protoent
*) getprotobyname(const char*);
447 int PASCAL
WSAStartup(WORD
,LPWSADATA
);
448 int PASCAL
WSACleanup(void);
449 void PASCAL
WSASetLastError(int);
450 int PASCAL
WSAGetLastError(void);
451 BOOL PASCAL
WSAIsBlocking(void);
452 int PASCAL
WSAUnhookBlockingHook(void);
453 FARPROC PASCAL
WSASetBlockingHook(FARPROC
);
454 int PASCAL
WSACancelBlockingCall(void);
455 HANDLE PASCAL
WSAAsyncGetServByName(HWND
,u_int
,const char*,const char*,char*,int);
456 HANDLE PASCAL
WSAAsyncGetServByPort(HWND
,u_int
,int,const char*,char*,int);
457 HANDLE PASCAL
WSAAsyncGetProtoByName(HWND
,u_int
,const char*,char*,int);
458 HANDLE PASCAL
WSAAsyncGetProtoByNumber(HWND
,u_int
,int,char*,int);
459 HANDLE PASCAL
WSAAsyncGetHostByName(HWND
,u_int
,const char*,char*,int);
460 HANDLE PASCAL
WSAAsyncGetHostByAddr(HWND
,u_int
,const char*,int,int,char*,int);
461 int PASCAL
WSACancelAsyncRequest(HANDLE
);
462 int PASCAL
WSAAsyncSelect(SOCKET
,HWND
,u_int
,long);
463 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
464 u_long PASCAL
htonl(u_long
);
465 u_long PASCAL
ntohl(u_long
);
466 u_short PASCAL
htons(u_short
);
467 u_short PASCAL
ntohs(u_short
);
468 int PASCAL
select(int nfds
,fd_set
*,fd_set
*,fd_set
*,const struct timeval
*);
469 int PASCAL
gethostname(char*,int);
470 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
472 #define WSAMAKEASYNCREPLY(b,e) MAKELONG(b,e)
473 #define WSAMAKESELECTREPLY(e,error) MAKELONG(e,error)
474 #define WSAGETASYNCBUFLEN(l) LOWORD(l)
475 #define WSAGETASYNCERROR(l) HIWORD(l)
476 #define WSAGETSELECTEVENT(l) LOWORD(l)
477 #define WSAGETSELECTERROR(l) HIWORD(l)
479 typedef struct sockaddr SOCKADDR
;
480 typedef struct sockaddr
*PSOCKADDR
;
481 typedef struct sockaddr
*LPSOCKADDR
;
482 typedef struct sockaddr_in SOCKADDR_IN
;
483 typedef struct sockaddr_in
*PSOCKADDR_IN
;
484 typedef struct sockaddr_in
*LPSOCKADDR_IN
;
485 typedef struct linger LINGER
;
486 typedef struct linger
*PLINGER
;
487 typedef struct linger
*LPLINGER
;
488 typedef struct in_addr IN_ADDR
;
489 typedef struct in_addr
*PIN_ADDR
;
490 typedef struct in_addr
*LPIN_ADDR
;
491 typedef struct fd_set FD_SET
;
492 typedef struct fd_set
*PFD_SET
;
493 typedef struct fd_set
*LPFD_SET
;
494 typedef struct hostent HOSTENT
;
495 typedef struct hostent
*PHOSTENT
;
496 typedef struct hostent
*LPHOSTENT
;
497 typedef struct servent SERVENT
;
498 typedef struct servent
*PSERVENT
;
499 typedef struct servent
*LPSERVENT
;
500 typedef struct protoent PROTOENT
;
501 typedef struct protoent
*PPROTOENT
;
502 typedef struct protoent
*LPPROTOENT
;
503 typedef struct timeval TIMEVAL
;
504 typedef struct timeval
*PTIMEVAL
;
505 typedef struct timeval
*LPTIMEVAL
;
511 * Recent MSDN docs indicate that the MS-specific extensions exported from
512 * mswsock.dll (AcceptEx, TransmitFile. WSARecEx and GetAcceptExSockaddrs) are
513 * declared in mswsock.h. These extensions are not supported on W9x or WinCE.
514 * However, code using WinSock 1.1 API may expect the declarations and
515 * associated defines to be in this header. Thus we include mswsock.h here.
517 * When linking against the WinSock 1.1 lib, wsock32.dll, the mswsock functions
518 * are automatically routed to mswsock.dll (on platforms with support).
519 * The WinSock 2 lib, ws2_32.dll, does not contain any references to
520 * the mswsock extensions.