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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 # ifndef __WINE_WINSOCK2__
25 # error Please use Winsock2 in Wine
29 #ifndef __WINE_WINSOCKAPI_STDLIB_H
30 #define __WINE_WINSOCKAPI_STDLIB_H
33 * This section defines the items that conflict with the Unix headers.
36 /* We are not using the WS_ prefix we risk getting conflicts for
37 * everything related to select.
40 /* Too late, the Unix version of stdlib.h was included before winsock.h.
41 * This means select and all the related stuff is already defined and we
42 * cannot override types and function prototypes.
43 * All we can do is disable all these symbols so that they are not used
52 # define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
53 # define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
54 # define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
55 # define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
56 # define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
57 # define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
58 # define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
60 /* stdlib.h has not been included yet so it's not too late. Include it now
61 * making sure that none of the select symbols is affected. Then we can
62 * define them with our own values.
64 # define fd_set unix_fd_set
65 # define timeval unix_timeval
66 # define select unix_select
67 # include <sys/types.h>
79 # define WS_DEFINE_SELECT
83 # define WS_DEFINE_SELECT
84 # include <sys/types.h>
86 #endif /* !USE_WS_PREFIX */
88 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
99 #if (defined(_MSC_VER) || defined(__MINGW_H)) && !defined(_BSD_TYPES_DEFINED)
100 /* MinGW doesn't define the u_xxx types */
101 typedef unsigned char u_char
;
102 typedef unsigned short u_short
;
103 typedef unsigned int u_int
;
104 typedef unsigned long u_long
;
108 # define WS(x) WS_##x
115 #endif /* defined(__cplusplus) */
117 /* proper 4-byte packing */
118 #include <pshpack4.h>
123 #ifndef USE_WS_PREFIX
133 #define AF_OSI AF_ISO
142 #define AF_APPLETALK 16
143 #define AF_NETBIOS 17
144 #define AF_VOICEVIEW 18
145 #define AF_FIREFOX 19
146 #define AF_UNKNOWN1 20
150 #define AF_CLUSTER 24
154 #define PF_UNSPEC AF_UNSPEC
155 #define PF_UNIX AF_UNIX
156 #define PF_INET AF_INET
157 #define PF_IMPLINK AF_IMPLINK
158 #define PF_PUP AF_PUP
159 #define PF_CHAOS AF_CHAOS
161 #define PF_IPX AF_IPX
162 #define PF_ISO AF_ISO
163 #define PF_OSI AF_OSI
164 #define PF_ECMA AF_ECMA
165 #define PF_DATAKIT AF_DATAKIT
166 #define PF_CCITT AF_CCITT
167 #define PF_SNA AF_SNA
168 #define PF_DECnet AF_DECnet
169 #define PF_DLI AF_DLI
170 #define PF_LAT AF_LAT
171 #define PF_HYLINK AF_HYLINK
172 #define PF_APPLETALK AF_APPLETALK
173 #define PF_VOICEVIEW AF_VOICEVIEW
174 #define PF_FIREFOX AF_FIREFOX
175 #define PF_UNKNOWN1 AF_UNKNOWN1
176 #define PF_BAN AF_BAN
177 #define PF_MAX AF_MAX
178 #else /* USE_WS_PREFIX */
179 #define WS_AF_UNSPEC 0
182 #define WS_AF_IMPLINK 3
184 #define WS_AF_CHAOS 5
186 #define WS_AF_IPX WS_AF_NS
188 #define WS_AF_OSI AF_ISO
190 #define WS_AF_DATAKIT 9
191 #define WS_AF_CCITT 10
193 #define WS_AF_DECnet 12
196 #define WS_AF_HYLINK 15
197 #define WS_AF_APPLETALK 16
198 #define WS_AF_NETBIOS 17
199 #define WS_AF_VOICEVIEW 18
200 #define WS_AF_FIREFOX 19
201 #define WS_AF_UNKNOWN1 20
204 #define WS_AF_INET6 23
205 #define WS_AF_CLUSTER 24
206 #define WS_AF_12844 25
207 #define WS_AF_IRDA 26
209 #endif /* USE_WS_PREFIX */
214 #ifndef USE_WS_PREFIX
215 #define SOCK_STREAM 1
219 #define SOCK_SEQPACKET 5
220 #else /* USE_WS_PREFIX */
221 #define WS_SOCK_STREAM 1
222 #define WS_SOCK_DGRAM 2
223 #define WS_SOCK_RAW 3
224 #define WS_SOCK_RDM 4
225 #define WS_SOCK_SEQPACKET 5
226 #endif /* USE_WS_PREFIX */
232 #ifndef USE_WS_PREFIX
234 #define IPPROTO_ICMP 1
235 #define IPPROTO_IGMP 2
236 #define IPPROTO_GGP 3
237 #define IPPROTO_TCP 6
238 #define IPPROTO_UDP 17
239 #define IPPROTO_IDP 22
240 #define IPPROTO_ND 77
241 #define IPPROTO_RAW 255
242 #define IPPROTO_MAX 256
243 #else /* USE_WS_PREFIX */
244 #define WS_IPPROTO_IP 0
245 #define WS_IPPROTO_ICMP 1
246 #define WS_IPPROTO_IGMP 2
247 #define WS_IPPROTO_GGP 3
248 #define WS_IPPROTO_TCP 6
249 #define WS_IPPROTO_UDP 17
250 #define WS_IPPROTO_IDP 22
251 #define WS_IPPROTO_ND 77
252 #define WS_IPPROTO_RAW 255
253 #define WS_IPPROTO_MAX 256
254 #endif /* USE_WS_PREFIX */
256 typedef struct WS(protoent
)
261 } PROTOENT
, *PPROTOENT
, *LPPROTOENT
;
270 char* n_name
; /* official name of net */
271 char** n_aliases
; /* alias list */
272 short n_addrtype
; /* net address type */
273 u_long n_net
; /* network # */
280 #ifndef USE_WS_PREFIX
281 #define IPPORT_ECHO 7
282 #define IPPORT_DISCARD 9
283 #define IPPORT_SYSTAT 11
284 #define IPPORT_DAYTIME 13
285 #define IPPORT_NETSTAT 15
286 #define IPPORT_FTP 21
287 #define IPPORT_TELNET 23
288 #define IPPORT_SMTP 25
289 #define IPPORT_TIMESERVER 37
290 #define IPPORT_NAMESERVER 42
291 #define IPPORT_WHOIS 43
292 #define IPPORT_MTP 57
293 #define IPPORT_TFTP 69
294 #define IPPORT_RJE 77
295 #define IPPORT_FINGER 79
296 #define IPPORT_TTYLINK 87
297 #define IPPORT_SUPDUP 95
298 #define IPPORT_EXECSERVER 512
299 #define IPPORT_LOGINSERVER 513
300 #define IPPORT_CMDSERVER 514
301 #define IPPORT_EFSSERVER 520
302 #define IPPORT_BIFFUDP 512
303 #define IPPORT_WHOSERVER 513
304 #define IPPORT_ROUTESERVER 520
305 #define IPPORT_RESERVED 1024
306 #else /* USE_WS_PREFIX */
307 #define WS_IPPORT_ECHO 7
308 #define WS_IPPORT_DISCARD 9
309 #define WS_IPPORT_SYSTAT 11
310 #define WS_IPPORT_DAYTIME 13
311 #define WS_IPPORT_NETSTAT 15
312 #define WS_IPPORT_FTP 21
313 #define WS_IPPORT_TELNET 23
314 #define WS_IPPORT_SMTP 25
315 #define WS_IPPORT_TIMESERVER 37
316 #define WS_IPPORT_NAMESERVER 42
317 #define WS_IPPORT_WHOIS 43
318 #define WS_IPPORT_MTP 57
319 #define WS_IPPORT_TFTP 69
320 #define WS_IPPORT_RJE 77
321 #define WS_IPPORT_FINGER 79
322 #define WS_IPPORT_TTYLINK 87
323 #define WS_IPPORT_SUPDUP 95
324 #define WS_IPPORT_EXECSERVER 512
325 #define WS_IPPORT_LOGINSERVER 513
326 #define WS_IPPORT_CMDSERVER 514
327 #define WS_IPPORT_EFSSERVER 520
328 #define WS_IPPORT_BIFFUDP 512
329 #define WS_IPPORT_WHOSERVER 513
330 #define WS_IPPORT_ROUTESERVER 520
331 #define WS_IPPORT_RESERVED 1024
332 #endif /* USE_WS_PREFIX */
334 typedef struct WS(servent
)
336 char* s_name
; /* official service name */
337 char** s_aliases
; /* alias list */
338 short s_port
; /* port # */
339 char* s_proto
; /* protocol to use */
340 } SERVENT
, *PSERVENT
, *LPSERVENT
;
348 typedef struct WS(hostent
)
350 char* h_name
; /* official name of host */
351 char** h_aliases
; /* alias list */
352 short h_addrtype
; /* host address type */
353 short h_length
; /* length of address */
354 char** h_addr_list
; /* list of addresses from name server */
355 #define h_addr h_addr_list[0] /* address, for backward compat */
356 } HOSTENT
, *PHOSTENT
, *LPHOSTENT
;
363 typedef UINT_PTR SOCKET
;
366 * This is used instead of -1, since the
367 * SOCKET type is unsigned.
369 #define INVALID_SOCKET (~0)
370 #define SOCKET_ERROR (-1)
372 typedef struct WS(sockaddr
)
376 } SOCKADDR
, *PSOCKADDR
, *LPSOCKADDR
;
378 typedef struct WS(linger
)
380 u_short l_onoff
; /* option on/off */
381 u_short l_linger
; /* linger time */
382 } LINGER
, *PLINGER
, *LPLINGER
;
388 #ifdef WS_DEFINE_SELECT
389 /* Define our own version of select and the associated types and macros */
391 # ifndef USE_WS_PREFIX
393 # define FD_SETSIZE 64
396 # ifndef WS_FD_SETSIZE
397 # define WS_FD_SETSIZE 64
401 typedef struct WS(fd_set
)
403 u_int fd_count
; /* how many are SET? */
404 # ifndef USE_WS_PREFIX
405 SOCKET fd_array
[FD_SETSIZE
]; /* an array of SOCKETs */
407 SOCKET fd_array
[WS_FD_SETSIZE
];/* an array of SOCKETs */
409 } WS(fd_set
), FD_SET
, *PFD_SET
, *LPFD_SET
;
411 #ifndef _TIMEVAL_DEFINED
412 #define _TIMEVAL_DEFINED
413 typedef struct WS(timeval
)
415 long tv_sec
; /* seconds */
416 long tv_usec
; /* and microseconds */
417 } TIMEVAL
, *PTIMEVAL
, *LPTIMEVAL
;
420 #define WINE_FD_CLR(fd, set, cast) do { \
422 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
424 if (((cast*)(set))->fd_array[__i] == fd) \
426 while (__i < ((cast*)(set))->fd_count-1) \
428 ((cast*)(set))->fd_array[__i] = \
429 ((cast*)(set))->fd_array[__i+1]; \
432 ((cast*)(set))->fd_count--; \
437 #define __WS_FD_SET1(fd, set, cast) do { \
438 if (((cast*)(set))->fd_count < FD_SETSIZE) \
439 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
441 /* This version checks if the filedesc is already in the list, and appends it
442 * only if it's not the case
444 #define __WS_FD_SET2(fd, set, cast) do { \
446 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
448 if (((cast*)(set))->fd_array[__i]==(fd)) \
451 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
453 ((cast*)(set))->fd_count++; \
454 ((cast*)(set))->fd_array[__i]=(fd);\
458 #ifndef __WINE_WINSOCK2__
459 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
461 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
464 #ifndef USE_WS_PREFIX
465 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
466 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
467 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
468 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
470 #define WS_FD_CLR(fd, set) WINE_FD_CLR((fd),(set), WS_fd_set)
471 #define WS_FD_SET(fd, set) WINE_FD_SET((fd),(set), WS_fd_set)
472 #define WS_FD_ZERO(set) ((WS_fd_set*)(set))->fd_count=0)
473 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
476 int WINAPI
__WSAFDIsSet(SOCKET
,WS(fd_set
)*);
478 #endif /* WS_DEFINE_SELECT */
480 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
481 #ifndef USE_WS_PREFIX
488 #ifdef WORDS_BIGENDIAN
490 #define htonl(l) ((u_long)(l))
491 #define htons(s) ((u_short)(s))
492 #define ntohl(l) ((u_long)(l))
493 #define ntohs(s) ((u_short)(s))
495 #else /* WORDS_BIGENDIAN */
497 inline static u_short
__wine_ushort_swap(u_short s
)
499 return (s
>> 8) | (s
<< 8);
501 inline static u_long
__wine_ulong_swap(u_long l
)
503 return ((u_long
)__wine_ushort_swap((u_short
)l
) << 16) | __wine_ushort_swap((u_short
)(l
>> 16));
505 #define htonl(l) __wine_ulong_swap(l)
506 #define htons(s) __wine_ushort_swap(s)
507 #define ntohl(l) __wine_ulong_swap(l)
508 #define ntohs(s) __wine_ushort_swap(s)
510 #endif /* WORDS_BIGENDIAN */
512 #endif /* USE_WS_PREFIX */
515 * Internet address (old style... should be updated)
518 #ifndef USE_WS_PREFIX
519 #define IN_CLASSA_NSHIFT 24
520 #define IN_CLASSA_MAX 128
521 #define IN_CLASSA_NET 0xff000000
522 #define IN_CLASSA_HOST 0x00ffffff
523 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
524 #define IN_CLASSB_NSHIFT 16
525 #define IN_CLASSB_MAX 65536
526 #define IN_CLASSB_NET 0xffff0000
527 #define IN_CLASSB_HOST 0x0000ffff
528 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
529 #define IN_CLASSC_NSHIFT 8
530 #define IN_CLASSC_NET 0xffffff00
531 #define IN_CLASSC_HOST 0x000000ff
532 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
534 #define WS_IN_CLASSA_NSHIFT 24
535 #define WS_IN_CLASSA_MAX 128
536 #define WS_IN_CLASSA_NET 0xff000000
537 #define WS_IN_CLASSA_HOST 0x00ffffff
538 #define WS_IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
539 #define WS_IN_CLASSB_NSHIFT 16
540 #define WS_IN_CLASSB_MAX 65536
541 #define WS_IN_CLASSB_NET 0xffff0000
542 #define WS_IN_CLASSB_HOST 0x0000ffff
543 #define WS_IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
544 #define WS_IN_CLASSC_NSHIFT 8
545 #define WS_IN_CLASSC_NET 0xffffff00
546 #define WS_IN_CLASSC_HOST 0x000000ff
547 #define WS_IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
548 #endif /* USE_WS_PREFIX */
550 #ifndef USE_WS_PREFIX
551 #define INADDR_ANY (u_long)0x00000000
552 #define INADDR_LOOPBACK 0x7f000001
553 #define INADDR_BROADCAST (u_long)0xffffffff
554 #define INADDR_NONE 0xffffffff
556 #define WS_INADDR_ANY (u_long)0x00000000
557 #define WS_INADDR_LOOPBACK 0x7f000001
558 #define WS_INADDR_BROADCAST (u_long)0xffffffff
559 #define WS_INADDR_NONE 0xffffffff
560 #endif /* USE_WS_PREFIX */
562 typedef struct WS(in_addr
)
566 u_char s_b1
,s_b2
,s_b3
,s_b4
;
573 #ifndef USE_WS_PREFIX
574 #define s_addr S_un.S_addr
575 #define s_host S_un.S_un_b.s_b2
576 #define s_net S_un.S_un_b.s_b1
577 #define s_imp S_un.S_un_w.s_w2
578 #define s_impno S_un.S_un_b.s_b4
579 #define s_lh S_un.S_un_b.s_b3
581 #define WS_s_addr S_un.S_addr
582 #define WS_s_host S_un.S_un_b.s_b2
583 #define WS_s_net S_un.S_un_b.s_b1
584 #define WS_s_imp S_un.S_un_w.s_w2
585 #define WS_s_impno S_un.S_un_b.s_b4
586 #define WS_s_lh S_un.S_un_b.s_b3
587 #endif /* USE_WS_PREFIX */
588 } IN_ADDR
, *PIN_ADDR
, *LPIN_ADDR
;
590 typedef struct WS(sockaddr_in
)
594 struct WS(in_addr
) sin_addr
;
596 } SOCKADDR_IN
, *PSOCKADDR_IN
, *LPSOCKADDR_IN
;
599 * Multicast group information
602 #if !defined(__WINE_WINSOCK2__)
605 struct WS(in_addr
) imr_multiaddr
;
606 struct WS(in_addr
) imr_interface
;
613 #define WSADESCRIPTION_LEN 256
614 #define WSASYS_STATUS_LEN 128
616 typedef struct WS(WSAData
)
620 char szDescription
[WSADESCRIPTION_LEN
+1];
621 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
625 } WSADATA
, *LPWSADATA
;
632 #ifndef USE_WS_PREFIX
633 #define SOL_SOCKET 0xffff
634 #define SO_DEBUG 0x0001
635 #define SO_ACCEPTCONN 0x0002
636 #define SO_REUSEADDR 0x0004
637 #define SO_KEEPALIVE 0x0008
638 #define SO_DONTROUTE 0x0010
639 #define SO_BROADCAST 0x0020
640 #define SO_USELOOPBACK 0x0040
641 #define SO_LINGER 0x0080
642 #define SO_OOBINLINE 0x0100
643 #define SO_DONTLINGER (u_int)(~SO_LINGER)
644 #define SO_SNDBUF 0x1001
645 #define SO_RCVBUF 0x1002
646 #define SO_SNDLOWAT 0x1003
647 #define SO_RCVLOWAT 0x1004
648 #define SO_SNDTIMEO 0x1005
649 #define SO_RCVTIMEO 0x1006
650 #define SO_ERROR 0x1007
651 #define SO_TYPE 0x1008
654 #define IOCPARM_MASK 0x7f
655 #define IOC_VOID 0x20000000
656 #define IOC_OUT 0x40000000
657 #define IOC_IN 0x80000000
658 #define IOC_INOUT (IOC_IN|IOC_OUT)
660 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
661 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
662 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
666 #define WS_SOL_SOCKET 0xffff
667 #define WS_SO_DEBUG 0x0001
668 #define WS_SO_ACCEPTCONN 0x0002
669 #define WS_SO_REUSEADDR 0x0004
670 #define WS_SO_KEEPALIVE 0x0008
671 #define WS_SO_DONTROUTE 0x0010
672 #define WS_SO_BROADCAST 0x0020
673 #define WS_SO_USELOOPBACK 0x0040
674 #define WS_SO_LINGER 0x0080
675 #define WS_SO_OOBINLINE 0x0100
676 #define WS_SO_DONTLINGER (u_int)(~WS_SO_LINGER)
677 #define WS_SO_SNDBUF 0x1001
678 #define WS_SO_RCVBUF 0x1002
679 #define WS_SO_SNDLOWAT 0x1003
680 #define WS_SO_RCVLOWAT 0x1004
681 #define WS_SO_SNDTIMEO 0x1005
682 #define WS_SO_RCVTIMEO 0x1006
683 #define WS_SO_ERROR 0x1007
684 #define WS_SO_TYPE 0x1008
686 #define WS_IOCPARM_MASK 0x7f
687 #define WS_IOC_VOID 0x20000000
688 #define WS_IOC_OUT 0x40000000
689 #define WS_IOC_IN 0x80000000
690 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
692 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
693 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
694 #define WS__IOW(x,y,t) (WS_IOC_IN|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
698 /* IPPROTO_TCP options */
699 #ifndef USE_WS_PREFIX
700 #define TCP_NODELAY 1
702 #define WS_TCP_NODELAY 1
705 /* IPPROTO_IP options */
706 #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
707 # ifndef USE_WS_PREFIX
708 # define IP_OPTIONS 1
709 # define IP_MULTICAST_IF 2
710 # define IP_MULTICAST_TTL 3
711 # define IP_MULTICAST_LOOP 4
712 # define IP_ADD_MEMBERSHIP 5
713 # define IP_DROP_MEMBERSHIP 6
716 # define IP_DONTFRAGMENT 9
718 # define WS_IP_OPTIONS 1
719 # define WS_IP_MULTICAST_IF 2
720 # define WS_IP_MULTICAST_TTL 3
721 # define WS_IP_MULTICAST_LOOP 4
722 # define WS_IP_ADD_MEMBERSHIP 5
723 # define WS_IP_DROP_MEMBERSHIP 6
726 # define WS_IP_DONTFRAGMENT 9
732 * Socket I/O flags (supported by spec 1.1)
734 #ifndef USE_WS_PREFIX
735 #define FIONREAD _IOR('f', 127, u_long)
736 #define FIONBIO _IOW('f', 126, u_long)
737 #define SIOCATMARK _IOR('s', 7, u_long)
739 #define WS_FIONREAD WS__IOR('f', 127, u_long)
740 #define WS_FIONBIO WS__IOW('f', 126, u_long)
741 #define WS_SIOCATMARK WS__IOR('s', 7, u_long)
745 * Maximum queue length specifiable by listen.
747 #ifndef USE_WS_PREFIX
750 #define MSG_OOB 0x0001
751 #define MSG_PEEK 0x0002
752 #define MSG_DONTROUTE 0x0004
753 #define MSG_MAXIOVLEN 0x000a
754 #define MSG_PARTIAL 0x8000
755 #else /* USE_WS_PREFIX */
756 #define WS_SOMAXCONN 5
758 #define WS_MSG_OOB 0x0001
759 #define WS_MSG_PEEK 0x0002
760 #define WS_MSG_DONTROUTE 0x0004
761 #define WS_MSG_MAXIOVLEN 0x000a
762 #define WS_MSG_PARTIAL 0x8000
763 #endif /* USE_WS_PREFIX */
766 * Define constant based on rfc883, used by gethostbyxxxx() calls.
768 #ifndef USE_WS_PREFIX
769 #define MAXGETHOSTSTRUCT 1024
771 #define MAXGETHOSTSTRUCT 1024
776 * Define flags to be used with the WSAAsyncSelect() call.
778 #define FD_READ 0x00000001
779 #define FD_WRITE 0x00000002
780 #define FD_OOB 0x00000004
781 #define FD_ACCEPT 0x00000008
782 #define FD_CONNECT 0x00000010
783 #define FD_CLOSE 0x00000020
785 /* internal per-socket flags */
787 #define FD_WINE_LISTENING 0x10000000
788 #define FD_WINE_NONBLOCKING 0x20000000
789 #define FD_WINE_CONNECTED 0x40000000
790 #define FD_WINE_RAW 0x80000000
791 #define FD_WINE_INTERNAL 0xFFFF0000
795 * All Windows Sockets error constants are biased by WSABASEERR from
798 #define WSABASEERR 10000
800 * Windows Sockets definitions of regular Microsoft C error constants
802 #define WSAEINTR (WSABASEERR+4)
803 #define WSAEBADF (WSABASEERR+9)
804 #define WSAEACCES (WSABASEERR+13)
805 #define WSAEFAULT (WSABASEERR+14)
806 #define WSAEINVAL (WSABASEERR+22)
807 #define WSAEMFILE (WSABASEERR+24)
810 * Windows Sockets definitions of regular Berkeley error constants
812 #define WSAEWOULDBLOCK (WSABASEERR+35)
813 #define WSAEINPROGRESS (WSABASEERR+36)
814 #define WSAEALREADY (WSABASEERR+37)
815 #define WSAENOTSOCK (WSABASEERR+38)
816 #define WSAEDESTADDRREQ (WSABASEERR+39)
817 #define WSAEMSGSIZE (WSABASEERR+40)
818 #define WSAEPROTOTYPE (WSABASEERR+41)
819 #define WSAENOPROTOOPT (WSABASEERR+42)
820 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
821 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
822 #define WSAEOPNOTSUPP (WSABASEERR+45)
823 #define WSAEPFNOSUPPORT (WSABASEERR+46)
824 #define WSAEAFNOSUPPORT (WSABASEERR+47)
825 #define WSAEADDRINUSE (WSABASEERR+48)
826 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
827 #define WSAENETDOWN (WSABASEERR+50)
828 #define WSAENETUNREACH (WSABASEERR+51)
829 #define WSAENETRESET (WSABASEERR+52)
830 #define WSAECONNABORTED (WSABASEERR+53)
831 #define WSAECONNRESET (WSABASEERR+54)
832 #define WSAENOBUFS (WSABASEERR+55)
833 #define WSAEISCONN (WSABASEERR+56)
834 #define WSAENOTCONN (WSABASEERR+57)
835 #define WSAESHUTDOWN (WSABASEERR+58)
836 #define WSAETOOMANYREFS (WSABASEERR+59)
837 #define WSAETIMEDOUT (WSABASEERR+60)
838 #define WSAECONNREFUSED (WSABASEERR+61)
839 #define WSAELOOP (WSABASEERR+62)
840 #define WSAENAMETOOLONG (WSABASEERR+63)
841 #define WSAEHOSTDOWN (WSABASEERR+64)
842 #define WSAEHOSTUNREACH (WSABASEERR+65)
843 #define WSAENOTEMPTY (WSABASEERR+66)
844 #define WSAEPROCLIM (WSABASEERR+67)
845 #define WSAEUSERS (WSABASEERR+68)
846 #define WSAEDQUOT (WSABASEERR+69)
847 #define WSAESTALE (WSABASEERR+70)
848 #define WSAEREMOTE (WSABASEERR+71)
849 #define WSAEDISCON (WSABASEERR+101)
852 * Extended Windows Sockets error constant definitions
854 #define WSASYSNOTREADY (WSABASEERR+91)
855 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
856 #define WSANOTINITIALISED (WSABASEERR+93)
857 #define WSAEDISCON (WSABASEERR+101)
858 #define WSAENOMORE (WSABASEERR+102)
859 #define WSAECANCELLED (WSABASEERR+103)
860 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
861 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
862 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
863 #define WSASYSCALLFAILURE (WSABASEERR+107)
864 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
865 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
866 #define WSA_E_NO_MORE (WSABASEERR+110)
867 #define WSA_E_CANCELLED (WSABASEERR+111)
868 #define WSAEREFUSED (WSABASEERR+112)
871 * Error return codes from gethostbyname() and gethostbyaddr()
872 * (when using the resolver). Note that these errors are
873 * retrieved via WSAGetLastError() and must therefore follow
874 * the rules for avoiding clashes with error numbers from
875 * specific implementations or language run-time systems.
876 * For this reason the codes are based at WSABASEERR+1001.
877 * Note also that [WSA]NO_ADDRESS is defined only for
878 * compatibility purposes.
881 #ifndef USE_WS_PREFIX
882 #define h_errno WSAGetLastError()
884 #define WS_h_errno WSAGetLastError()
887 /* Authoritative Answer: Host not found */
888 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
890 /* Non-Authoritative: Host not found, or SERVERFAIL */
891 #define WSATRY_AGAIN (WSABASEERR+1002)
893 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
894 #define WSANO_RECOVERY (WSABASEERR+1003)
896 /* Valid name, no data record of requested type */
897 #define WSANO_DATA (WSABASEERR+1004)
899 /* no address, look for MX record */
900 #define WSANO_ADDRESS WSANO_DATA
902 #ifndef USE_WS_PREFIX
903 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
904 #define TRY_AGAIN WSATRY_AGAIN
905 #define NO_RECOVERY WSANO_RECOVERY
906 #define NO_DATA WSANO_DATA
907 #define NO_ADDRESS WSANO_ADDRESS
908 #endif /* USE_WS_PREFIX */
913 * Windows message parameter composition and decomposition
918 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
919 * when constructing the response to a WSAAsyncGetXByY() routine.
921 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
923 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
924 * when constructing the response to WSAAsyncSelect().
926 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
928 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
929 * to extract the buffer length from the lParam in the response
932 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
934 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
935 * to extract the error code from the lParam in the response
938 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
940 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
941 * to extract the event code from the lParam in the response
942 * to a WSAAsyncSelect().
944 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
946 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
947 * to extract the error code from the lParam in the response
948 * to a WSAAsyncSelect().
950 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
957 * Remember to keep this section in sync with the
958 * "Winsock Function Typedefs" section in winsock2.h.
960 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
961 HANDLE WINAPI
WSAAsyncGetHostByAddr(HWND
,u_int
,const char*,int,int,char*,int);
962 HANDLE WINAPI
WSAAsyncGetHostByName(HWND
,u_int
,const char*,char*,int);
963 HANDLE WINAPI
WSAAsyncGetProtoByName(HWND
,u_int
,const char*,char*,int);
964 HANDLE WINAPI
WSAAsyncGetProtoByNumber(HWND
,u_int
,int,char*,int);
965 HANDLE WINAPI
WSAAsyncGetServByName(HWND
,u_int
,const char*,const char*,char*,int);
966 HANDLE WINAPI
WSAAsyncGetServByPort(HWND
,u_int
,int,const char*,char*,int);
967 int WINAPI
WSAAsyncSelect(SOCKET
,HWND
,u_int
,long);
968 int WINAPI
WSACancelAsyncRequest(HANDLE
);
969 int WINAPI
WSACancelBlockingCall(void);
970 int WINAPI
WSACleanup(void);
971 int WINAPI
WSAGetLastError(void);
972 BOOL WINAPI
WSAIsBlocking(void);
973 FARPROC WINAPI
WSASetBlockingHook(FARPROC
);
974 void WINAPI
WSASetLastError(int);
975 int WINAPI
WSAStartup(WORD
,LPWSADATA
);
976 int WINAPI
WSAUnhookBlockingHook(void);
978 SOCKET WINAPI
WS(accept
)(SOCKET
,struct WS(sockaddr
)*,int*);
979 int WINAPI
WS(bind
)(SOCKET
,const struct WS(sockaddr
)*,int);
980 int WINAPI
WS(closesocket
)(SOCKET
);
981 int WINAPI
WS(connect
)(SOCKET
,const struct WS(sockaddr
)*,int);
982 struct WS(hostent
)* WINAPI
WS(gethostbyaddr
)(const char*,int,int);
983 struct WS(hostent
)* WINAPI
WS(gethostbyname
)(const char*);
984 /* gethostname not defined because of conflicts with unistd.h */
985 int WINAPI
WS(getpeername
)(SOCKET
,struct WS(sockaddr
)*,int*);
986 struct WS(protoent
)* WINAPI
WS(getprotobyname
)(const char*);
987 struct WS(protoent
)* WINAPI
WS(getprotobynumber
)(int);
988 #ifdef WS_DEFINE_SELECT
989 int WINAPI
WS(select
)(int,WS(fd_set
)*,WS(fd_set
)*,WS(fd_set
)*,const struct WS(timeval
)*);
991 struct WS(servent
)* WINAPI
WS(getservbyname
)(const char*,const char*);
992 struct WS(servent
)* WINAPI
WS(getservbyport
)(int,const char*);
993 int WINAPI
WS(getsockname
)(SOCKET
,struct WS(sockaddr
)*,int*);
994 int WINAPI
WS(getsockopt
)(SOCKET
,int,int,char*,int*);
995 unsigned long WINAPI
WS(inet_addr
)(const char*);
996 char* WINAPI
WS(inet_ntoa
)(struct WS(in_addr
));
997 int WINAPI
WS(ioctlsocket
)(SOCKET
,long,u_long
*);
998 int WINAPI
WS(listen
)(SOCKET
,int);
999 int WINAPI
WS(recv
)(SOCKET
,char*,int,int);
1000 int WINAPI
WS(recvfrom
)(SOCKET
,char*,int,int,struct WS(sockaddr
)*,int*);
1001 int WINAPI
WS(send
)(SOCKET
,const char*,int,int);
1002 int WINAPI
WS(sendto
)(SOCKET
,const char*,int,int,const struct WS(sockaddr
)*,int);
1003 int WINAPI
WS(setsockopt
)(SOCKET
,int,int,const char*,int);
1004 int WINAPI
WS(shutdown
)(SOCKET
,int);
1005 SOCKET WINAPI
WS(socket
)(int,int,int);
1007 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1010 #include <poppack.h>
1016 #ifndef __WINE_WINSOCK2__
1018 #undef WS_API_PROTOTYPES
1019 #undef WS_API_TYPEDEFS
1022 #endif /* _WINSOCKAPI_ */