2 Definitions for winsock 1.1
4 Portions Copyright (c) 1980, 1983, 1988, 1993
5 The Regents of the University of California. All rights reserved.
7 Portions Copyright (c) 1993 by Digital Equipment Corporation.
19 #if !defined(__ROS_LONG64__)
21 #define __ROS_LONG64__
26 #define _GNU_H_WINDOWS32_SOCKETS
32 #if !defined ( _BSDTYPES_DEFINED )
34 /* also defined in gmon.h and in cygwin's sys/types */
35 typedef unsigned char u_char
;
36 typedef unsigned short u_short
;
37 typedef unsigned int u_int
;
39 #ifndef __ROS_LONG64__
40 typedef unsigned long u_long
;
42 typedef unsigned int u_long
;
45 #define _BSDTYPES_DEFINED
47 #endif /* !defined ( _BSDTYPES_DEFINED ) */
49 typedef UINT_PTR SOCKET
;
55 /* shutdown() how types */
56 #define SD_RECEIVE 0x00
60 #ifndef _SYS_TYPES_FD_SET
62 /* fd_set may have be defined by the newlib <sys/types.h>
63 * if __USE_W32_SOCKETS not defined.
68 typedef struct fd_set
{
70 SOCKET fd_array
[FD_SETSIZE
];
73 extern int PASCAL
__WSAFDIsSet(SOCKET
,fd_set FAR
*);
76 #define FD_CLR(fd,set) do { u_int __i;\
77 for (__i = 0; __i < ((fd_set FAR*)(set))->fd_count ; __i++) {\
78 if (((fd_set FAR*)(set))->fd_array[__i] == (fd)) {\
79 while (__i < ((fd_set FAR*)(set))->fd_count-1) {\
80 ((fd_set FAR*)(set))->fd_array[__i] = ((fd_set FAR*)(set))->fd_array[__i+1];\
83 ((fd_set FAR*)(set))->fd_count--;\
91 #define FD_SET(fd, set) do { \
92 if (((fd_set FAR*)(set))->fd_count < FD_SETSIZE) \
93 ((fd_set FAR*)(set))->fd_array[((fd_set FAR*)(set))->fd_count++]=(fd);\
98 #define FD_ZERO(set) (((fd_set FAR*)(set))->fd_count=0)
102 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR*)(set))
107 #elif !defined(USE_SYS_TYPES_FD_SET)
108 #warning "fd_set and associated macros have been defined in sys/types. \
109 This can cause runtime problems with W32 sockets"
110 #endif /* ndef _SYS_TYPES_FD_SET */
112 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
114 #ifndef _TIMEVAL_DEFINED /* also in sys/time.h */
115 #define _TIMEVAL_DEFINED
122 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
124 #define timercmp(tvp, uvp, cmp) \
125 (((tvp)->tv_sec != (uvp)->tv_sec) ? \
126 ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
127 ((tvp)->tv_usec cmp (uvp)->tv_usec))
129 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
131 #endif /* _TIMEVAL_DEFINED */
133 #define h_addr h_addr_list[0]
148 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
149 #define _IOR(x,y,t) (IOC_OUT|(((LONG)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
150 #define _IOW(x,y,t) (IOC_IN|(((LONG)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
151 #define FIONBIO _IOW('f', 126, u_long)
181 #define SO_ACCEPTCONN 2
182 #define SO_REUSEADDR 4
183 #define SO_KEEPALIVE 8
184 #define SO_DONTROUTE 16
185 #define SO_BROADCAST 32
186 #define SO_USELOOPBACK 64
187 #define SO_LINGER 128
188 #define SO_OOBINLINE 256
189 #define SO_DONTLINGER (u_int)(~SO_LINGER)
190 #define SO_SNDBUF 0x1001
191 #define SO_RCVBUF 0x1002
192 #define SO_SNDLOWAT 0x1003
193 #define SO_RCVLOWAT 0x1004
194 #define SO_SNDTIMEO 0x1005
195 #define SO_RCVTIMEO 0x1006
196 #define SO_ERROR 0x1007
197 #define SO_TYPE 0x1008
199 #define SO_CONNDATA 0x7000
200 #define SO_CONNOPT 0x7001
201 #define SO_DISCDATA 0x7002
202 #define SO_DISCOPT 0x7003
203 #define SO_CONNDATALEN 0x7004
204 #define SO_CONNOPTLEN 0x7005
205 #define SO_DISCDATALEN 0x7006
206 #define SO_DISCOPTLEN 0x7007
207 #define SO_OPENTYPE 0x7008
208 #define SO_MAXDG 0x7009
209 #define SO_MAXPATHDG 0x700A
210 #define SO_UPDATE_ACCEPT_CONTEXT 0x700B
211 #define SO_CONNECT_TIME 0x700C
213 #define SO_SYNCHRONOUS_ALERT 0x10
214 #define SO_SYNCHRONOUS_NONALERT 0x20
225 #define MSG_DONTROUTE 4
227 #define h_errno WSAGetLastError()
228 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
229 #define TRY_AGAIN WSATRY_AGAIN
230 #define NO_RECOVERY WSANO_RECOVERY
231 #define NO_DATA WSANO_DATA
232 #define NO_ADDRES WSANO_ADDRESS
234 u_long PASCAL
htonl(u_long
);
235 u_long PASCAL
ntohl(u_long
);
236 u_short PASCAL
htons(u_short
);
237 u_short PASCAL
ntohs(u_short
);
238 int PASCAL
select(int nfds
,fd_set
*,fd_set
*,fd_set
*,const struct timeval
*);
239 int PASCAL
gethostname(char*,int);
241 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
243 #define IOCPARM_MASK 0x7f
244 #define IOC_VOID 0x20000000
245 #define IOC_OUT 0x40000000
246 #define IOC_IN 0x80000000
247 #define IOC_INOUT (IOC_IN|IOC_OUT)
249 #define FIONREAD _IOR('f', 127, u_long)
250 #define FIOASYNC _IOW('f', 125, u_long)
251 #define SIOCSHIWAT _IOW('s', 0, u_long)
252 #define SIOCGHIWAT _IOR('s', 1, u_long)
253 #define SIOCSLOWAT _IOW('s', 2, u_long)
254 #define SIOCGLOWAT _IOR('s', 3, u_long)
255 #define SIOCATMARK _IOR('s', 7, u_long)
258 #define IPPROTO_ICMP 1
259 #define IPPROTO_IGMP 2
260 #define IPPROTO_GGP 3
261 #define IPPROTO_TCP 6
262 #define IPPROTO_PUP 12
263 #define IPPROTO_UDP 17
264 #define IPPROTO_IDP 22
265 #define IPPROTO_ND 77
266 #define IPPROTO_RAW 255
267 #define IPPROTO_MAX 256
268 #define IPPORT_ECHO 7
269 #define IPPORT_DISCARD 9
270 #define IPPORT_SYSTAT 11
271 #define IPPORT_DAYTIME 13
272 #define IPPORT_NETSTAT 15
273 #define IPPORT_FTP 21
274 #define IPPORT_TELNET 23
275 #define IPPORT_SMTP 25
276 #define IPPORT_TIMESERVER 37
277 #define IPPORT_NAMESERVER 42
278 #define IPPORT_WHOIS 43
279 #define IPPORT_MTP 57
280 #define IPPORT_TFTP 69
281 #define IPPORT_RJE 77
282 #define IPPORT_FINGER 79
283 #define IPPORT_TTYLINK 87
284 #define IPPORT_SUPDUP 95
285 #define IPPORT_EXECSERVER 512
286 #define IPPORT_LOGINSERVER 513
287 #define IPPORT_CMDSERVER 514
288 #define IPPORT_EFSSERVER 520
289 #define IPPORT_BIFFUDP 512
290 #define IPPORT_WHOSERVER 513
291 #define IPPORT_ROUTESERVER 520
292 #define IPPORT_RESERVED 1024
293 #define IMPLINK_IP 155
294 #define IMPLINK_LOWEXPER 156
295 #define IMPLINK_HIGHEXPER 158
299 #define IN_CLASSA(i) ((LONG)(i)&0x80000000)
300 #define IN_CLASSA_NET 0xff000000
301 #define IN_CLASSA_NSHIFT 24
302 #define IN_CLASSA_HOST 0x00ffffff
303 #define IN_CLASSA_MAX 128
304 #define IN_CLASSB(i) (((LONG)(i)&0xc0000000)==0x80000000)
305 #define IN_CLASSB_NET 0xffff0000
306 #define IN_CLASSB_NSHIFT 16
307 #define IN_CLASSB_HOST 0x0000ffff
308 #define IN_CLASSB_MAX 65536
309 #define IN_CLASSC(i) (((LONG)(i)&0xe0000000)==0xc0000000)
310 #define IN_CLASSC_NET 0xffffff00
311 #define IN_CLASSC_NSHIFT 8
312 #define IN_CLASSC_HOST 0xff
313 #define INADDR_ANY (u_long)0
314 #define INADDR_LOOPBACK 0x7f000001
315 #define INADDR_BROADCAST (u_long)0xffffffff
316 #define INADDR_NONE 0xffffffff
318 #define WSADESCRIPTION_LEN 256
319 #define WSASYS_STATUS_LEN 128
321 #define IP_MULTICAST_IF 2
322 #define IP_MULTICAST_TTL 3
323 #define IP_MULTICAST_LOOP 4
324 #define IP_ADD_MEMBERSHIP 5
325 #define IP_DROP_MEMBERSHIP 6
328 #define IP_DONTFRAGMENT 9
330 #define IP_DEFAULT_MULTICAST_TTL 1
331 #define IP_DEFAULT_MULTICAST_LOOP 1
332 #define IP_MAX_MEMBERSHIPS 20
334 #define INVALID_SOCKET (SOCKET)(~0)
335 #define SOCKET_ERROR (-1)
337 #define SOCK_STREAM 1
341 #define SOCK_SEQPACKET 5
343 #define TCP_NODELAY 0x0001
344 #define TCP_BSDURGENT 0x7000
355 #define AF_OSI AF_ISO
364 #define AF_APPLETALK 16
365 #define AF_NETBIOS 17
366 #define AF_VOICEVIEW 18
367 #define AF_FIREFOX 19
368 #define AF_UNKNOWN1 20
373 #define PF_UNSPEC AF_UNSPEC
374 #define PF_UNIX AF_UNIX
375 #define PF_INET AF_INET
376 #define PF_IMPLINK AF_IMPLINK
377 #define PF_PUP AF_PUP
378 #define PF_CHAOS AF_CHAOS
380 #define PF_IPX AF_IPX
381 #define PF_ISO AF_ISO
382 #define PF_OSI AF_OSI
383 #define PF_ECMA AF_ECMA
384 #define PF_DATAKIT AF_DATAKIT
385 #define PF_CCITT AF_CCITT
386 #define PF_SNA AF_SNA
387 #define PF_DECnet AF_DECnet
388 #define PF_DLI AF_DLI
389 #define PF_LAT AF_LAT
390 #define PF_HYLINK AF_HYLINK
391 #define PF_APPLETALK AF_APPLETALK
392 #define PF_VOICEVIEW AF_VOICEVIEW
393 #define PF_FIREFOX AF_FIREFOX
394 #define PF_UNKNOWN1 AF_UNKNOWN1
395 #define PF_BAN AF_BAN
396 #define PF_ATM AF_ATM
397 #define PF_INET6 AF_INET6
398 #define PF_MAX AF_MAX
400 #define SOL_SOCKET 0xffff
403 #define MSG_MAXIOVLEN 16
404 #define MSG_PARTIAL 0x8000
405 #define MAXGETHOSTSTRUCT 1024
411 #define FD_CONNECT 16
416 #define WSABASEERR 10000
417 #define WSAEINTR (WSABASEERR+4)
418 #define WSAEBADF (WSABASEERR+9)
419 #define WSAEACCES (WSABASEERR+13)
420 #define WSAEFAULT (WSABASEERR+14)
421 #define WSAEINVAL (WSABASEERR+22)
422 #define WSAEMFILE (WSABASEERR+24)
423 #define WSAEWOULDBLOCK (WSABASEERR+35)
424 #define WSAEINPROGRESS (WSABASEERR+36)
425 #define WSAEALREADY (WSABASEERR+37)
426 #define WSAENOTSOCK (WSABASEERR+38)
427 #define WSAEDESTADDRREQ (WSABASEERR+39)
428 #define WSAEMSGSIZE (WSABASEERR+40)
429 #define WSAEPROTOTYPE (WSABASEERR+41)
430 #define WSAENOPROTOOPT (WSABASEERR+42)
431 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
432 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
433 #define WSAEOPNOTSUPP (WSABASEERR+45)
434 #define WSAEPFNOSUPPORT (WSABASEERR+46)
435 #define WSAEAFNOSUPPORT (WSABASEERR+47)
436 #define WSAEADDRINUSE (WSABASEERR+48)
437 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
438 #define WSAENETDOWN (WSABASEERR+50)
439 #define WSAENETUNREACH (WSABASEERR+51)
440 #define WSAENETRESET (WSABASEERR+52)
441 #define WSAECONNABORTED (WSABASEERR+53)
442 #define WSAECONNRESET (WSABASEERR+54)
443 #define WSAENOBUFS (WSABASEERR+55)
444 #define WSAEISCONN (WSABASEERR+56)
445 #define WSAENOTCONN (WSABASEERR+57)
446 #define WSAESHUTDOWN (WSABASEERR+58)
447 #define WSAETOOMANYREFS (WSABASEERR+59)
448 #define WSAETIMEDOUT (WSABASEERR+60)
449 #define WSAECONNREFUSED (WSABASEERR+61)
450 #define WSAELOOP (WSABASEERR+62)
451 #define WSAENAMETOOLONG (WSABASEERR+63)
452 #define WSAEHOSTDOWN (WSABASEERR+64)
453 #define WSAEHOSTUNREACH (WSABASEERR+65)
454 #define WSAENOTEMPTY (WSABASEERR+66)
455 #define WSAEPROCLIM (WSABASEERR+67)
456 #define WSAEUSERS (WSABASEERR+68)
457 #define WSAEDQUOT (WSABASEERR+69)
458 #define WSAESTALE (WSABASEERR+70)
459 #define WSAEREMOTE (WSABASEERR+71)
460 #define WSASYSNOTREADY (WSABASEERR+91)
461 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
462 #define WSANOTINITIALISED (WSABASEERR+93)
463 #define WSAEDISCON (WSABASEERR+101)
464 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
465 #define WSATRY_AGAIN (WSABASEERR+1002)
466 #define WSANO_RECOVERY (WSABASEERR+1003)
467 #define WSANO_DATA (WSABASEERR+1004)
468 #define WSA_SECURE_HOST_NOT_FOUND (WSABASEERR+1032)
469 #define WSA_IPSEC_NAME_POLICY_ERROR (WSABASEERR+1033)
471 #endif /* !WSABASEERR */
473 #define WSANO_ADDRESS WSANO_DATA
475 #define TF_DISCONNECT 0x01
476 #define TF_REUSE_SOCKET 0x02
477 #define TF_WRITE_BEHIND 0x04
479 #define WSAMAKEASYNCREPLY(b,e) MAKELONG(b,e)
480 #define WSAMAKESELECTREPLY(e,error) MAKELONG(e,error)
481 #define WSAGETASYNCBUFLEN(l) LOWORD(l)
482 #define WSAGETASYNCERROR(l) HIWORD(l)
483 #define WSAGETSELECTEVENT(l) LOWORD(l)
484 #define WSAGETSELECTERROR(l) HIWORD(l)
486 typedef struct sockaddr SOCKADDR
;
487 typedef struct sockaddr
*PSOCKADDR
;
488 typedef struct sockaddr
*LPSOCKADDR
;
489 typedef struct sockaddr_in SOCKADDR_IN
;
490 typedef struct sockaddr_in
*PSOCKADDR_IN
;
491 typedef struct sockaddr_in
*LPSOCKADDR_IN
;
492 typedef struct linger LINGER
;
493 typedef struct linger
*PLINGER
;
494 typedef struct linger
*LPLINGER
;
495 typedef struct fd_set FD_SET
;
496 typedef struct fd_set
*PFD_SET
;
497 typedef struct fd_set
*LPFD_SET
;
498 typedef struct hostent HOSTENT
;
499 typedef struct hostent
*PHOSTENT
;
500 typedef struct hostent
*LPHOSTENT
;
501 typedef struct servent SERVENT
;
502 typedef struct servent
*PSERVENT
;
503 typedef struct servent
*LPSERVENT
;
504 typedef struct protoent PROTOENT
;
505 typedef struct protoent
*PPROTOENT
;
506 typedef struct protoent
*LPPROTOENT
;
507 typedef struct timeval TIMEVAL
;
508 typedef struct timeval
*PTIMEVAL
;
509 typedef struct timeval
*LPTIMEVAL
;
514 struct in_addr sin_addr
;
518 typedef struct WSAData
{
522 unsigned short iMaxSockets
;
523 unsigned short iMaxUdpDg
;
525 char szDescription
[WSADESCRIPTION_LEN
+1];
526 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
528 char szDescription
[WSADESCRIPTION_LEN
+1];
529 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
530 unsigned short iMaxSockets
;
531 unsigned short iMaxUdpDg
;
534 } WSADATA
, FAR
*LPWSADATA
;
537 struct in_addr imr_multiaddr
;
538 struct in_addr imr_interface
;
550 OUT
struct sockaddr FAR
*addr OPTIONAL
,
551 IN OUT
int FAR
*addrlen OPTIONAL
);
557 IN
const struct sockaddr FAR
*addr
,
569 IN
const struct sockaddr FAR
*name
,
577 IN OUT u_long FAR
*argp
);
583 OUT
struct sockaddr FAR
*name
,
584 IN OUT
int FAR
*namelen
);
590 OUT
struct sockaddr FAR
*name
,
591 IN OUT
int FAR
*namelen
);
599 OUT
char FAR
*optval
,
600 IN OUT
int FAR
*optlen
);
610 IN u_short hostshort
);
615 IN
const char FAR
*cp
);
620 IN
struct in_addr in
);
636 IN u_short netshort
);
653 OUT
struct sockaddr FAR
*from OPTIONAL
,
654 IN OUT
int FAR
* fromlen OPTIONAL
);
660 IN OUT fd_set FAR
*readfds OPTIONAL
,
661 IN OUT fd_set FAR
*writefds OPTIONAL
,
662 IN OUT fd_set FAR
*exceptfds OPTIONAL
,
663 IN
const struct timeval FAR
*timeout OPTIONAL
);
669 IN
const char FAR
*buf
,
677 IN
const char FAR
*buf
,
680 IN
const struct sockaddr FAR
*to OPTIONAL
,
689 IN
const char FAR
*optval OPTIONAL
,
708 IN
const char FAR
*addr
,
715 IN
const char FAR
*name
);
727 IN
const char FAR
*proto
);
732 IN
const char FAR
*name
,
733 IN
const char FAR
*proto
);
743 IN
const char FAR
*name
);
748 IN WORD wVersionRequired
,
749 OUT LPWSADATA lpWSAData
);
762 WSAGetLastError(void);
770 WSAUnhookBlockingHook(void);
775 IN FARPROC lpBlockFunc
);
779 WSACancelBlockingCall(void);
783 WSAAsyncGetServByName(
786 IN
const char FAR
*name
,
787 IN
const char FAR
*proto
,
793 WSAAsyncGetServByPort(
797 IN
const char FAR
*proto
,
803 WSAAsyncGetProtoByName(
806 IN
const char FAR
*name
,
812 WSAAsyncGetProtoByNumber(
821 WSAAsyncGetHostByName(
824 IN
const char FAR
*name
,
830 WSAAsyncGetHostByAddr(
833 IN
const char FAR
*addr
,
841 WSACancelAsyncRequest(
842 IN HANDLE hAsyncTaskHandle
);
858 IN OUT
int FAR
*flags
);
860 typedef struct _TRANSMIT_FILE_BUFFERS
{
865 } TRANSMIT_FILE_BUFFERS
, *PTRANSMIT_FILE_BUFFERS
, *LPTRANSMIT_FILE_BUFFERS
;
872 IN DWORD nNumberOfBytesToWrite
,
873 IN DWORD nNumberOfBytesPerSend
,
874 IN OUT LPOVERLAPPED lpOverlapped OPTIONAL
,
875 IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers OPTIONAL
,
876 IN DWORD dwReserved
);
881 IN SOCKET sListenSocket
,
882 IN SOCKET sAcceptSocket
,
883 OUT PVOID lpOutputBuffer
,
884 IN DWORD dwReceiveDataLength
,
885 IN DWORD dwLocalAddressLength
,
886 IN DWORD dwRemoteAddressLength
,
887 OUT LPDWORD lpdwBytesReceived
,
888 IN OUT LPOVERLAPPED lpOverlapped
);
892 GetAcceptExSockaddrs(
893 IN PVOID lpOutputBuffer
,
894 IN DWORD dwReceiveDataLength
,
895 IN DWORD dwLocalAddressLength
,
896 IN DWORD dwRemoteAddressLength
,
897 OUT
struct sockaddr
**LocalSockaddr
,
898 OUT LPINT LocalSockaddrLength
,
899 OUT
struct sockaddr
**RemoteSockaddr
,
900 OUT LPINT RemoteSockaddrLength
);
902 #if(_WIN32_WINNT >= 0x0501)
905 #error WINSOCK2 required.
908 #endif /* (_WIN32_WINNT >= 0x0501) */