1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
6 * Copyright (C) the Wine project
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 # error Please use winsock2 in Wine
27 #ifndef __WINE_WINSOCKAPI_STDLIB_H
28 #define __WINE_WINSOCKAPI_STDLIB_H
31 * This section defines the items that conflict with the Unix headers.
34 /* We are not using the WS_ prefix we risk getting conflicts for
35 * everything related to select.
38 /* Too late, the Unix version of stdlib.h was included before winsock.h.
39 * This means select and all the related stuff is already defined and we
40 * cannot override types and function prototypes.
41 * All we can do is disable all these symbols so that they are not used
44 # include <sys/types.h>
51 # define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
52 # define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
53 # define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
54 # define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
55 # define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
56 # define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
57 # define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
58 # elif defined(RLIM_INFINITY)
59 /* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */
60 # define fd_set unix_fd_set
61 # include <sys/types.h>
70 # define select Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
71 # define timeval Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
73 /* stdlib.h has not been included yet so it's not too late. Include it now
74 * making sure that none of the select symbols is affected. Then we can
75 * define them with our own values.
77 # define fd_set unix_fd_set
78 # define timeval unix_timeval
79 # define select unix_select
80 # define socklen_t unix_socklen_t
81 # define u_long unix_u_long
82 # include <sys/types.h>
95 # undef _TIMEVAL_DEFINED
97 # define WS_DEFINE_SELECT
101 # define WS_DEFINE_SELECT
102 # include <sys/types.h>
104 #endif /* !USE_WS_PREFIX */
106 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
115 #ifndef WINSOCK_API_LINKAGE
117 # define WINSOCK_API_LINKAGE
119 # define WINSOCK_API_LINKAGE DECLSPEC_IMPORT
124 typedef unsigned char WS_u_char
;
125 typedef unsigned short WS_u_short
;
126 typedef unsigned int WS_u_int
;
127 typedef ULONG WS_u_long
;
128 #elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
129 /* MinGW doesn't define the u_xxx types */
130 typedef unsigned char u_char
;
131 typedef unsigned short u_short
;
132 typedef unsigned int u_int
;
133 typedef ULONG u_long
;
134 #define _BSDTYPES_DEFINED
136 #define u_long ULONG /* make sure we don't use the system u_long */
140 # define WS(x) WS_##x
147 #endif /* defined(__cplusplus) */
152 #ifndef USE_WS_PREFIX
162 #define AF_OSI AF_ISO
171 #define AF_APPLETALK 16
172 #define AF_NETBIOS 17
173 #define AF_VOICEVIEW 18
174 #define AF_FIREFOX 19
175 #define AF_UNKNOWN1 20
178 #define PF_UNSPEC AF_UNSPEC
179 #define PF_UNIX AF_UNIX
180 #define PF_INET AF_INET
181 #define PF_IMPLINK AF_IMPLINK
182 #define PF_PUP AF_PUP
183 #define PF_CHAOS AF_CHAOS
185 #define PF_IPX AF_IPX
186 #define PF_ISO AF_ISO
187 #define PF_OSI AF_OSI
188 #define PF_ECMA AF_ECMA
189 #define PF_DATAKIT AF_DATAKIT
190 #define PF_CCITT AF_CCITT
191 #define PF_SNA AF_SNA
192 #define PF_DECnet AF_DECnet
193 #define PF_DLI AF_DLI
194 #define PF_LAT AF_LAT
195 #define PF_HYLINK AF_HYLINK
196 #define PF_APPLETALK AF_APPLETALK
197 #define PF_VOICEVIEW AF_VOICEVIEW
198 #define PF_FIREFOX AF_FIREFOX
199 #define PF_UNKNOWN1 AF_UNKNOWN1
200 #define PF_BAN AF_BAN
201 #define PF_MAX AF_MAX
202 #else /* USE_WS_PREFIX */
203 #define WS_AF_UNSPEC 0
206 #define WS_AF_IMPLINK 3
208 #define WS_AF_CHAOS 5
210 #define WS_AF_IPX WS_AF_NS
212 #define WS_AF_OSI AF_ISO
214 #define WS_AF_DATAKIT 9
215 #define WS_AF_CCITT 10
217 #define WS_AF_DECnet 12
220 #define WS_AF_HYLINK 15
221 #define WS_AF_APPLETALK 16
222 #define WS_AF_NETBIOS 17
223 #define WS_AF_VOICEVIEW 18
224 #define WS_AF_FIREFOX 19
225 #define WS_AF_UNKNOWN1 20
228 #endif /* USE_WS_PREFIX */
233 #ifndef USE_WS_PREFIX
234 #define SOCK_STREAM 1
238 #define SOCK_SEQPACKET 5
239 #else /* USE_WS_PREFIX */
240 #define WS_SOCK_STREAM 1
241 #define WS_SOCK_DGRAM 2
242 #define WS_SOCK_RAW 3
243 #define WS_SOCK_RDM 4
244 #define WS_SOCK_SEQPACKET 5
245 #endif /* USE_WS_PREFIX */
251 #ifndef USE_WS_PREFIX
253 #define IPPROTO_ICMP 1
254 #define IPPROTO_IGMP 2
255 #define IPPROTO_GGP 3
256 #define IPPROTO_TCP 6
257 #define IPPROTO_UDP 17
258 #define IPPROTO_IDP 22
259 #define IPPROTO_ND 77
260 #define IPPROTO_RAW 255
261 #define IPPROTO_MAX 256
262 #else /* USE_WS_PREFIX */
263 #define WS_IPPROTO_IP 0
264 #define WS_IPPROTO_ICMP 1
265 #define WS_IPPROTO_IGMP 2
266 #define WS_IPPROTO_GGP 3
267 #define WS_IPPROTO_TCP 6
268 #define WS_IPPROTO_UDP 17
269 #define WS_IPPROTO_IDP 22
270 #define WS_IPPROTO_ND 77
271 #define WS_IPPROTO_RAW 255
272 #define WS_IPPROTO_MAX 256
273 #endif /* USE_WS_PREFIX */
275 typedef struct WS(protoent
)
280 } PROTOENT
, *PPROTOENT
, *LPPROTOENT
;
289 char* n_name
; /* official name of net */
290 char** n_aliases
; /* alias list */
291 short n_addrtype
; /* net address type */
292 ULONG n_net
; /* network # */
299 #ifndef USE_WS_PREFIX
300 #define IPPORT_ECHO 7
301 #define IPPORT_DISCARD 9
302 #define IPPORT_SYSTAT 11
303 #define IPPORT_DAYTIME 13
304 #define IPPORT_NETSTAT 15
305 #define IPPORT_FTP 21
306 #define IPPORT_TELNET 23
307 #define IPPORT_SMTP 25
308 #define IPPORT_TIMESERVER 37
309 #define IPPORT_NAMESERVER 42
310 #define IPPORT_WHOIS 43
311 #define IPPORT_MTP 57
312 #define IPPORT_TFTP 69
313 #define IPPORT_RJE 77
314 #define IPPORT_FINGER 79
315 #define IPPORT_TTYLINK 87
316 #define IPPORT_SUPDUP 95
317 #define IPPORT_EXECSERVER 512
318 #define IPPORT_LOGINSERVER 513
319 #define IPPORT_CMDSERVER 514
320 #define IPPORT_EFSSERVER 520
321 #define IPPORT_BIFFUDP 512
322 #define IPPORT_WHOSERVER 513
323 #define IPPORT_ROUTESERVER 520
324 #define IPPORT_RESERVED 1024
325 #else /* USE_WS_PREFIX */
326 #define WS_IPPORT_ECHO 7
327 #define WS_IPPORT_DISCARD 9
328 #define WS_IPPORT_SYSTAT 11
329 #define WS_IPPORT_DAYTIME 13
330 #define WS_IPPORT_NETSTAT 15
331 #define WS_IPPORT_FTP 21
332 #define WS_IPPORT_TELNET 23
333 #define WS_IPPORT_SMTP 25
334 #define WS_IPPORT_TIMESERVER 37
335 #define WS_IPPORT_NAMESERVER 42
336 #define WS_IPPORT_WHOIS 43
337 #define WS_IPPORT_MTP 57
338 #define WS_IPPORT_TFTP 69
339 #define WS_IPPORT_RJE 77
340 #define WS_IPPORT_FINGER 79
341 #define WS_IPPORT_TTYLINK 87
342 #define WS_IPPORT_SUPDUP 95
343 #define WS_IPPORT_EXECSERVER 512
344 #define WS_IPPORT_LOGINSERVER 513
345 #define WS_IPPORT_CMDSERVER 514
346 #define WS_IPPORT_EFSSERVER 520
347 #define WS_IPPORT_BIFFUDP 512
348 #define WS_IPPORT_WHOSERVER 513
349 #define WS_IPPORT_ROUTESERVER 520
350 #define WS_IPPORT_RESERVED 1024
351 #endif /* USE_WS_PREFIX */
353 typedef struct WS(servent
)
355 char* s_name
; /* official service name */
356 char** s_aliases
; /* alias list */
358 char* s_proto
; /* protocol to use */
359 short s_port
; /* port # */
361 short s_port
; /* port # */
362 char* s_proto
; /* protocol to use */
364 } SERVENT
, *PSERVENT
, *LPSERVENT
;
372 typedef struct WS(hostent
)
374 char* h_name
; /* official name of host */
375 char** h_aliases
; /* alias list */
376 short h_addrtype
; /* host address type */
377 short h_length
; /* length of address */
378 char** h_addr_list
; /* list of addresses from name server */
379 #define h_addr h_addr_list[0] /* address, for backward compat */
380 } HOSTENT
, *PHOSTENT
, *LPHOSTENT
;
387 typedef UINT_PTR SOCKET
;
390 * This is used instead of -1, since the
391 * SOCKET type is unsigned.
393 #define INVALID_SOCKET (SOCKET)(~0)
394 #define SOCKET_ERROR (-1)
396 typedef struct WS(sockaddr
)
398 WS(u_short
) sa_family
;
400 } SOCKADDR
, *PSOCKADDR
, *LPSOCKADDR
;
402 typedef struct WS(linger
)
404 WS(u_short
) l_onoff
; /* option on/off */
405 WS(u_short
) l_linger
; /* linger time */
406 } LINGER
, *PLINGER
, *LPLINGER
;
412 #ifdef WS_DEFINE_SELECT
413 /* Define our own version of select and the associated types and macros */
415 # ifndef USE_WS_PREFIX
417 # define FD_SETSIZE 64
420 # ifndef WS_FD_SETSIZE
421 # define WS_FD_SETSIZE 64
425 typedef struct WS(fd_set
)
427 WS(u_int
) fd_count
; /* how many are SET? */
428 # ifndef USE_WS_PREFIX
429 SOCKET fd_array
[FD_SETSIZE
]; /* an array of SOCKETs */
431 SOCKET fd_array
[WS_FD_SETSIZE
];/* an array of SOCKETs */
433 } WS(fd_set
), FD_SET
, *PFD_SET
, *LPFD_SET
;
435 #ifndef _TIMEVAL_DEFINED
436 #define _TIMEVAL_DEFINED
437 typedef struct WS(timeval
)
439 LONG tv_sec
; /* seconds */
440 LONG tv_usec
; /* and microseconds */
441 } TIMEVAL
, *PTIMEVAL
, *LPTIMEVAL
;
444 #define __WS_FD_CLR(fd, set, cast) do { \
446 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
448 if (((cast*)(set))->fd_array[__i] == fd) \
450 while (__i < ((cast*)(set))->fd_count-1) \
452 ((cast*)(set))->fd_array[__i] = \
453 ((cast*)(set))->fd_array[__i+1]; \
456 ((cast*)(set))->fd_count--; \
462 #define __WS_FD_SET(fd, set, cast) do { \
463 if (((cast*)(set))->fd_count < FD_SETSIZE) \
464 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
467 #ifndef USE_WS_PREFIX
468 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
469 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
470 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
471 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
473 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
474 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
475 #define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
476 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
479 WINSOCK_API_LINKAGE
int WINAPI
__WSAFDIsSet(SOCKET
,WS(fd_set
)*);
481 #endif /* WS_DEFINE_SELECT */
484 * Internet address (old style... should be updated)
487 #ifndef USE_WS_PREFIX
488 #define IN_CLASSA_NSHIFT 24
489 #define IN_CLASSA_MAX 128
490 #define IN_CLASSA_NET 0xff000000
491 #define IN_CLASSA_HOST 0x00ffffff
492 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
493 #define IN_CLASSB_NSHIFT 16
494 #define IN_CLASSB_MAX 65536
495 #define IN_CLASSB_NET 0xffff0000
496 #define IN_CLASSB_HOST 0x0000ffff
497 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
498 #define IN_CLASSC_NSHIFT 8
499 #define IN_CLASSC_NET 0xffffff00
500 #define IN_CLASSC_HOST 0x000000ff
501 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
503 #define WS_IN_CLASSA_NSHIFT 24
504 #define WS_IN_CLASSA_MAX 128
505 #define WS_IN_CLASSA_NET 0xff000000
506 #define WS_IN_CLASSA_HOST 0x00ffffff
507 #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
508 #define WS_IN_CLASSB_NSHIFT 16
509 #define WS_IN_CLASSB_MAX 65536
510 #define WS_IN_CLASSB_NET 0xffff0000
511 #define WS_IN_CLASSB_HOST 0x0000ffff
512 #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
513 #define WS_IN_CLASSC_NSHIFT 8
514 #define WS_IN_CLASSC_NET 0xffffff00
515 #define WS_IN_CLASSC_HOST 0x000000ff
516 #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
517 #endif /* USE_WS_PREFIX */
519 #ifndef USE_WS_PREFIX
520 #define INADDR_ANY ((ULONG)0x00000000)
521 #define INADDR_LOOPBACK 0x7f000001
522 #define INADDR_BROADCAST ((ULONG)0xffffffff)
523 #define INADDR_NONE 0xffffffff
525 #define WS_INADDR_ANY ((ULONG)0x00000000)
526 #define WS_INADDR_LOOPBACK 0x7f000001
527 #define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
528 #define WS_INADDR_NONE 0xffffffff
529 #endif /* USE_WS_PREFIX */
531 typedef struct WS(sockaddr_in
)
534 WS(u_short
) sin_port
;
535 struct WS(in_addr
) sin_addr
;
537 } SOCKADDR_IN
, *PSOCKADDR_IN
, *LPSOCKADDR_IN
;
540 * Multicast group information
545 struct WS(in_addr
) imr_multiaddr
;
546 struct WS(in_addr
) imr_interface
;
552 #define WSADESCRIPTION_LEN 256
553 #define WSASYS_STATUS_LEN 128
555 typedef struct WS(WSAData
)
563 char szDescription
[WSADESCRIPTION_LEN
+1];
564 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
566 char szDescription
[WSADESCRIPTION_LEN
+1];
567 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
572 } WSADATA
, *LPWSADATA
;
579 #ifndef USE_WS_PREFIX
580 #define SOL_SOCKET 0xffff
581 #define SO_DEBUG 0x0001
582 #define SO_ACCEPTCONN 0x0002
583 #define SO_REUSEADDR 0x0004
584 #define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
585 #define SO_KEEPALIVE 0x0008
586 #define SO_DONTROUTE 0x0010
587 #define SO_BROADCAST 0x0020
588 #define SO_USELOOPBACK 0x0040
589 #define SO_LINGER 0x0080
590 #define SO_OOBINLINE 0x0100
591 #define SO_DONTLINGER ((u_int)(~SO_LINGER))
592 #define SO_SNDBUF 0x1001
593 #define SO_RCVBUF 0x1002
594 #define SO_SNDLOWAT 0x1003
595 #define SO_RCVLOWAT 0x1004
596 #define SO_SNDTIMEO 0x1005
597 #define SO_RCVTIMEO 0x1006
598 #define SO_ERROR 0x1007
599 #define SO_TYPE 0x1008
601 #define IOCPARM_MASK 0x7f
602 #define IOC_VOID 0x20000000
603 #define IOC_OUT 0x40000000
604 #define IOC_IN 0x80000000
605 #define IOC_INOUT (IOC_IN|IOC_OUT)
607 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
608 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
609 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
613 #define WS_SOL_SOCKET 0xffff
614 #define WS_SO_DEBUG 0x0001
615 #define WS_SO_ACCEPTCONN 0x0002
616 #define WS_SO_REUSEADDR 0x0004
617 #define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
618 #define WS_SO_KEEPALIVE 0x0008
619 #define WS_SO_DONTROUTE 0x0010
620 #define WS_SO_BROADCAST 0x0020
621 #define WS_SO_USELOOPBACK 0x0040
622 #define WS_SO_LINGER 0x0080
623 #define WS_SO_OOBINLINE 0x0100
624 #define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
625 #define WS_SO_SNDBUF 0x1001
626 #define WS_SO_RCVBUF 0x1002
627 #define WS_SO_SNDLOWAT 0x1003
628 #define WS_SO_RCVLOWAT 0x1004
629 #define WS_SO_SNDTIMEO 0x1005
630 #define WS_SO_RCVTIMEO 0x1006
631 #define WS_SO_ERROR 0x1007
632 #define WS_SO_TYPE 0x1008
634 #define WS_IOCPARM_MASK 0x7f
635 #define WS_IOC_VOID 0x20000000
636 #define WS_IOC_OUT 0x40000000
637 #define WS_IOC_IN 0x80000000
638 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
640 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
641 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
642 #define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
646 /* IPPROTO_TCP options */
647 #ifndef USE_WS_PREFIX
648 #define TCP_NODELAY 1
650 #define WS_TCP_NODELAY 1
653 #ifndef USE_WS_PREFIX
654 # define IP_OPTIONS 1
655 # define IP_MULTICAST_IF 2
656 # define IP_MULTICAST_TTL 3
657 # define IP_MULTICAST_LOOP 4
658 # define IP_ADD_MEMBERSHIP 5
659 # define IP_DROP_MEMBERSHIP 6
662 # define IP_DONTFRAGMENT 9
664 # define WS_IP_OPTIONS 1
665 # define WS_IP_MULTICAST_IF 2
666 # define WS_IP_MULTICAST_TTL 3
667 # define WS_IP_MULTICAST_LOOP 4
668 # define WS_IP_ADD_MEMBERSHIP 5
669 # define WS_IP_DROP_MEMBERSHIP 6
672 # define WS_IP_DONTFRAGMENT 9
677 * Socket I/O flags (supported by spec 1.1)
679 #ifndef USE_WS_PREFIX
680 #define FIONREAD _IOR('f', 127, ULONG)
681 #define FIONBIO _IOW('f', 126, ULONG)
682 #define FIOASYNC _IOW('f', 125, ULONG)
683 #define SIOCSHIWAT _IOW('s', 0, ULONG)
684 #define SIOCGHIWAT _IOR('s', 1, ULONG)
685 #define SIOCSLOWAT _IOW('s', 2, ULONG)
686 #define SIOCGLOWAT _IOR('s', 3, ULONG)
687 #define SIOCATMARK _IOR('s', 7, ULONG)
689 #define WS_FIONREAD WS__IOR('f', 127, ULONG)
690 #define WS_FIONBIO WS__IOW('f', 126, ULONG)
691 #define WS_FIOASYNC WS__IOW('f', 125, ULONG)
692 #define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG)
693 #define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG)
694 #define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG)
695 #define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG)
696 #define WS_SIOCATMARK WS__IOR('s', 7, ULONG)
700 * Maximum queue length specifiable by listen.
702 #ifndef USE_WS_PREFIX
705 #define MSG_OOB 0x0001
706 #define MSG_PEEK 0x0002
707 #define MSG_DONTROUTE 0x0004
708 #define MSG_PARTIAL 0x8000
709 #define MSG_MAXIOVLEN 16
710 #else /* USE_WS_PREFIX */
711 #define WS_SOMAXCONN 5
713 #define WS_MSG_OOB 0x0001
714 #define WS_MSG_PEEK 0x0002
715 #define WS_MSG_DONTROUTE 0x0004
716 #define WS_MSG_PARTIAL 0x8000
717 #define WS_MSG_MAXIOVLEN 16
718 #endif /* USE_WS_PREFIX */
721 * Define constant based on rfc883, used by gethostbyxxxx() calls.
723 #ifndef USE_WS_PREFIX
724 #define MAXGETHOSTSTRUCT 1024
726 #define MAXGETHOSTSTRUCT 1024
731 * Define flags to be used with the WSAAsyncSelect() call.
733 #define FD_READ 0x00000001
734 #define FD_WRITE 0x00000002
735 #define FD_OOB 0x00000004
736 #define FD_ACCEPT 0x00000008
737 #define FD_CONNECT 0x00000010
738 #define FD_CLOSE 0x00000020
741 * All Windows Sockets error constants are biased by WSABASEERR from
742 * the "normal". They are also defined in winerror.h.
744 #define WSABASEERR 10000
746 * Windows Sockets definitions of regular Microsoft C error constants
748 #define WSAEINTR (WSABASEERR+4)
749 #define WSAEBADF (WSABASEERR+9)
750 #define WSAEACCES (WSABASEERR+13)
751 #define WSAEFAULT (WSABASEERR+14)
752 #define WSAEINVAL (WSABASEERR+22)
753 #define WSAEMFILE (WSABASEERR+24)
756 * Windows Sockets definitions of regular Berkeley error constants
758 #define WSAEWOULDBLOCK (WSABASEERR+35)
759 #define WSAEINPROGRESS (WSABASEERR+36)
760 #define WSAEALREADY (WSABASEERR+37)
761 #define WSAENOTSOCK (WSABASEERR+38)
762 #define WSAEDESTADDRREQ (WSABASEERR+39)
763 #define WSAEMSGSIZE (WSABASEERR+40)
764 #define WSAEPROTOTYPE (WSABASEERR+41)
765 #define WSAENOPROTOOPT (WSABASEERR+42)
766 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
767 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
768 #define WSAEOPNOTSUPP (WSABASEERR+45)
769 #define WSAEPFNOSUPPORT (WSABASEERR+46)
770 #define WSAEAFNOSUPPORT (WSABASEERR+47)
771 #define WSAEADDRINUSE (WSABASEERR+48)
772 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
773 #define WSAENETDOWN (WSABASEERR+50)
774 #define WSAENETUNREACH (WSABASEERR+51)
775 #define WSAENETRESET (WSABASEERR+52)
776 #define WSAECONNABORTED (WSABASEERR+53)
777 #define WSAECONNRESET (WSABASEERR+54)
778 #define WSAENOBUFS (WSABASEERR+55)
779 #define WSAEISCONN (WSABASEERR+56)
780 #define WSAENOTCONN (WSABASEERR+57)
781 #define WSAESHUTDOWN (WSABASEERR+58)
782 #define WSAETOOMANYREFS (WSABASEERR+59)
783 #define WSAETIMEDOUT (WSABASEERR+60)
784 #define WSAECONNREFUSED (WSABASEERR+61)
785 #define WSAELOOP (WSABASEERR+62)
786 #define WSAENAMETOOLONG (WSABASEERR+63)
787 #define WSAEHOSTDOWN (WSABASEERR+64)
788 #define WSAEHOSTUNREACH (WSABASEERR+65)
789 #define WSAENOTEMPTY (WSABASEERR+66)
790 #define WSAEPROCLIM (WSABASEERR+67)
791 #define WSAEUSERS (WSABASEERR+68)
792 #define WSAEDQUOT (WSABASEERR+69)
793 #define WSAESTALE (WSABASEERR+70)
794 #define WSAEREMOTE (WSABASEERR+71)
797 * Extended Windows Sockets error constant definitions
799 #define WSASYSNOTREADY (WSABASEERR+91)
800 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
801 #define WSANOTINITIALISED (WSABASEERR+93)
802 #define WSAEDISCON (WSABASEERR+101)
805 * Error return codes from gethostbyname() and gethostbyaddr()
806 * (when using the resolver). Note that these errors are
807 * retrieved via WSAGetLastError() and must therefore follow
808 * the rules for avoiding clashes with error numbers from
809 * specific implementations or language run-time systems.
810 * For this reason the codes are based at WSABASEERR+1001.
811 * Note also that [WSA]NO_ADDRESS is defined only for
812 * compatibility purposes.
815 #ifndef USE_WS_PREFIX
816 #define h_errno WSAGetLastError()
818 #define WS_h_errno WSAGetLastError()
821 /* Authoritative Answer: Host not found */
822 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
824 /* Non-Authoritative: Host not found, or SERVERFAIL */
825 #define WSATRY_AGAIN (WSABASEERR+1002)
827 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
828 #define WSANO_RECOVERY (WSABASEERR+1003)
830 /* Valid name, no data record of requested type */
831 #define WSANO_DATA (WSABASEERR+1004)
833 /* no address, look for MX record */
834 #define WSANO_ADDRESS WSANO_DATA
836 #ifndef USE_WS_PREFIX
837 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
838 #define TRY_AGAIN WSATRY_AGAIN
839 #define NO_RECOVERY WSANO_RECOVERY
840 #define NO_DATA WSANO_DATA
841 #define NO_ADDRESS WSANO_ADDRESS
842 #endif /* USE_WS_PREFIX */
847 * Windows message parameter composition and decomposition
852 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
853 * when constructing the response to a WSAAsyncGetXByY() routine.
855 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
857 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
858 * when constructing the response to WSAAsyncSelect().
860 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
862 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
863 * to extract the buffer length from the lParam in the response
866 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
868 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
869 * to extract the error code from the lParam in the response
872 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
874 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
875 * to extract the event code from the lParam in the response
876 * to a WSAAsyncSelect().
878 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
880 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
881 * to extract the error code from the lParam in the response
882 * to a WSAAsyncSelect().
884 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
891 * Remember to keep this section in sync with the
892 * "Winsock Function Typedefs" section in winsock2.h.
894 WINSOCK_API_LINKAGE HANDLE WINAPI
WSAAsyncGetHostByAddr(HWND
,WS(u_int
),const char*,int,int,char*,int);
895 WINSOCK_API_LINKAGE HANDLE WINAPI
WSAAsyncGetHostByName(HWND
,WS(u_int
),const char*,char*,int);
896 WINSOCK_API_LINKAGE HANDLE WINAPI
WSAAsyncGetProtoByName(HWND
,WS(u_int
),const char*,char*,int);
897 WINSOCK_API_LINKAGE HANDLE WINAPI
WSAAsyncGetProtoByNumber(HWND
,WS(u_int
),int,char*,int);
898 WINSOCK_API_LINKAGE HANDLE WINAPI
WSAAsyncGetServByName(HWND
,WS(u_int
),const char*,const char*,char*,int);
899 WINSOCK_API_LINKAGE HANDLE WINAPI
WSAAsyncGetServByPort(HWND
,WS(u_int
),int,const char*,char*,int);
900 WINSOCK_API_LINKAGE
int WINAPI
WSAAsyncSelect(SOCKET
,HWND
,WS(u_int
),LONG
);
901 WINSOCK_API_LINKAGE
int WINAPI
WSACancelAsyncRequest(HANDLE
);
902 WINSOCK_API_LINKAGE
int WINAPI
WSACancelBlockingCall(void);
903 WINSOCK_API_LINKAGE
int WINAPI
WSACleanup(void);
904 WINSOCK_API_LINKAGE
int WINAPI
WSAGetLastError(void);
905 WINSOCK_API_LINKAGE BOOL WINAPI
WSAIsBlocking(void);
906 WINSOCK_API_LINKAGE FARPROC WINAPI
WSASetBlockingHook(FARPROC
);
907 WINSOCK_API_LINKAGE
void WINAPI
WSASetLastError(int);
908 WINSOCK_API_LINKAGE
int WINAPI
WSAStartup(WORD
,LPWSADATA
);
909 WINSOCK_API_LINKAGE
int WINAPI
WSAUnhookBlockingHook(void);
911 WINSOCK_API_LINKAGE SOCKET WINAPI
WS(accept
)(SOCKET
,struct WS(sockaddr
)*,int*);
912 WINSOCK_API_LINKAGE
int WINAPI
WS(bind
)(SOCKET
,const struct WS(sockaddr
)*,int);
913 WINSOCK_API_LINKAGE
int WINAPI
WS(closesocket
)(SOCKET
);
914 WINSOCK_API_LINKAGE
int WINAPI
WS(connect
)(SOCKET
,const struct WS(sockaddr
)*,int);
915 WINSOCK_API_LINKAGE
struct WS(hostent
)* WINAPI
WS(gethostbyaddr
)(const char*,int,int);
916 WINSOCK_API_LINKAGE
struct WS(hostent
)* WINAPI
WS(gethostbyname
)(const char*);
917 WINSOCK_API_LINKAGE
int WINAPI
WS(getpeername
)(SOCKET
,struct WS(sockaddr
)*,int*);
918 WINSOCK_API_LINKAGE
struct WS(protoent
)* WINAPI
WS(getprotobyname
)(const char*);
919 WINSOCK_API_LINKAGE
struct WS(protoent
)* WINAPI
WS(getprotobynumber
)(int);
920 #ifdef WS_DEFINE_SELECT
921 WINSOCK_API_LINKAGE
int WINAPI
WS(select
)(int,WS(fd_set
)*,WS(fd_set
)*,WS(fd_set
)*,const struct WS(timeval
)*);
923 WINSOCK_API_LINKAGE
struct WS(servent
)* WINAPI
WS(getservbyname
)(const char*,const char*);
924 WINSOCK_API_LINKAGE
struct WS(servent
)* WINAPI
WS(getservbyport
)(int,const char*);
925 WINSOCK_API_LINKAGE
int WINAPI
WS(getsockname
)(SOCKET
,struct WS(sockaddr
)*,int*);
926 WINSOCK_API_LINKAGE
int WINAPI
WS(getsockopt
)(SOCKET
,int,int,char*,int*);
927 WINSOCK_API_LINKAGE ULONG WINAPI
WS(htonl
)(ULONG
);
928 WINSOCK_API_LINKAGE
WS(u_short
) WINAPI
WS(htons
)(WS(u_short
));
929 WINSOCK_API_LINKAGE ULONG WINAPI
WS(inet_addr
)(const char*);
930 WINSOCK_API_LINKAGE
char* WINAPI
WS(inet_ntoa
)(struct WS(in_addr
));
931 WINSOCK_API_LINKAGE
int WINAPI
WS(ioctlsocket
)(SOCKET
,LONG
,ULONG
*);
932 WINSOCK_API_LINKAGE
int WINAPI
WS(listen
)(SOCKET
,int);
933 WINSOCK_API_LINKAGE ULONG WINAPI
WS(ntohl
)(ULONG
);
934 WINSOCK_API_LINKAGE
WS(u_short
) WINAPI
WS(ntohs
)(WS(u_short
));
935 WINSOCK_API_LINKAGE
int WINAPI
WS(recv
)(SOCKET
,char*,int,int);
936 WINSOCK_API_LINKAGE
int WINAPI
WS(recvfrom
)(SOCKET
,char*,int,int,struct WS(sockaddr
)*,int*);
937 WINSOCK_API_LINKAGE
int WINAPI
WS(send
)(SOCKET
,const char*,int,int);
938 WINSOCK_API_LINKAGE
int WINAPI
WS(sendto
)(SOCKET
,const char*,int,int,const struct WS(sockaddr
)*,int);
939 WINSOCK_API_LINKAGE
int WINAPI
WS(setsockopt
)(SOCKET
,int,int,const char*,int);
940 WINSOCK_API_LINKAGE
int WINAPI
WS(shutdown
)(SOCKET
,int);
941 WINSOCK_API_LINKAGE SOCKET WINAPI
WS(socket
)(int,int,int);
943 #if defined(__MINGW32__) || defined (_MSC_VER) || defined(__WINE_USE_MSVCRT)
944 /* gethostname is not defined on Unix because of conflicts with unistd.h */
945 WINSOCK_API_LINKAGE
int WINAPI
WS(gethostname
)(char*,int);
954 #endif /* _WINSOCKAPI_ */