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
59 # define htonl Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
60 # define htons Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
61 # define ntohl Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
62 # define ntohs Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
64 /* stdlib.h has not been included yet so it's not too late. Include it now
65 * making sure that none of the select symbols is affected. Then we can
66 * define them with our own values.
68 # define fd_set unix_fd_set
69 # define timeval unix_timeval
70 # define select unix_select
71 # define htonl unix_htonl
72 # define htons unix_htons
73 # define ntohl unix_ntohl
74 # define ntohs unix_ntohs
75 # include <sys/types.h>
90 # define WS_DEFINE_SELECT
94 # define WS_DEFINE_SELECT
95 # include <sys/types.h>
97 #endif /* !USE_WS_PREFIX */
99 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
102 # include "windows.h"
110 #if defined(__MINGW_H) && !defined(MSVCRT_BSD_TYPES_DEFINED)
111 /* MinGW doesn't define the u_xxx types */
112 typedef unsigned char u_char
;
113 typedef unsigned short u_short
;
114 typedef unsigned int u_int
;
115 typedef unsigned long u_long
;
119 # define WS(x) WS_##x
126 #endif /* defined(__cplusplus) */
128 /* proper 4-byte packing */
129 #include "pshpack4.h"
134 #ifndef USE_WS_PREFIX
144 #define AF_OSI AF_ISO
153 #define AF_APPLETALK 16
154 #define AF_NETBIOS 17
155 #define AF_VOICEVIEW 18
156 #define AF_FIREFOX 19
157 #define AF_UNKNOWN1 20
161 #define AF_CLUSTER 24
165 #define PF_UNSPEC AF_UNSPEC
166 #define PF_UNIX AF_UNIX
167 #define PF_INET AF_INET
168 #define PF_IMPLINK AF_IMPLINK
169 #define PF_PUP AF_PUP
170 #define PF_CHAOS AF_CHAOS
172 #define PF_IPX AF_IPX
173 #define PF_ISO AF_ISO
174 #define PF_OSI AF_OSI
175 #define PF_ECMA AF_ECMA
176 #define PF_DATAKIT AF_DATAKIT
177 #define PF_CCITT AF_CCITT
178 #define PF_SNA AF_SNA
179 #define PF_DECnet AF_DECnet
180 #define PF_DLI AF_DLI
181 #define PF_LAT AF_LAT
182 #define PF_HYLINK AF_HYLINK
183 #define PF_APPLETALK AF_APPLETALK
184 #define PF_VOICEVIEW AF_VOICEVIEW
185 #define PF_FIREFOX AF_FIREFOX
186 #define PF_UNKNOWN1 AF_UNKNOWN1
187 #define PF_BAN AF_BAN
188 #define PF_MAX AF_MAX
189 #else /* USE_WS_PREFIX */
190 #define WS_AF_UNSPEC 0
193 #define WS_AF_IMPLINK 3
195 #define WS_AF_CHAOS 5
197 #define WS_AF_IPX WS_AF_NS
199 #define WS_AF_OSI AF_ISO
201 #define WS_AF_DATAKIT 9
202 #define WS_AF_CCITT 10
204 #define WS_AF_DECnet 12
207 #define WS_AF_HYLINK 15
208 #define WS_AF_APPLETALK 16
209 #define WS_AF_NETBIOS 17
210 #define WS_AF_VOICEVIEW 18
211 #define WS_AF_FIREFOX 19
212 #define WS_AF_UNKNOWN1 20
215 #define WS_AF_INET6 23
216 #define WS_AF_CLUSTER 24
217 #define WS_AF_12844 25
218 #define WS_AF_IRDA 26
220 #endif /* USE_WS_PREFIX */
225 #ifndef USE_WS_PREFIX
226 #define SOCK_STREAM 1
230 #define SOCK_SEQPACKET 5
231 #else /* USE_WS_PREFIX */
232 #define WS_SOCK_STREAM 1
233 #define WS_SOCK_DGRAM 2
234 #define WS_SOCK_RAW 3
235 #define WS_SOCK_RDM 4
236 #define WS_SOCK_SEQPACKET 5
237 #endif /* USE_WS_PREFIX */
243 #ifndef USE_WS_PREFIX
245 #define IPPROTO_ICMP 1
246 #define IPPROTO_IGMP 2
247 #define IPPROTO_GGP 3
248 #define IPPROTO_TCP 6
249 #define IPPROTO_UDP 17
250 #define IPPROTO_IDP 22
251 #define IPPROTO_ND 77
252 #define IPPROTO_RAW 255
253 #define IPPROTO_MAX 256
254 #else /* USE_WS_PREFIX */
255 #define WS_IPPROTO_IP 0
256 #define WS_IPPROTO_ICMP 1
257 #define WS_IPPROTO_IGMP 2
258 #define WS_IPPROTO_GGP 3
259 #define WS_IPPROTO_TCP 6
260 #define WS_IPPROTO_UDP 17
261 #define WS_IPPROTO_IDP 22
262 #define WS_IPPROTO_ND 77
263 #define WS_IPPROTO_RAW 255
264 #define WS_IPPROTO_MAX 256
265 #endif /* USE_WS_PREFIX */
267 typedef struct WS(protoent
)
272 } PROTOENT
, *PPROTOENT
, *LPPROTOENT
;
281 char* n_name
; /* official name of net */
282 char** n_aliases
; /* alias list */
283 short n_addrtype
; /* net address type */
284 u_long n_net
; /* network # */
291 #ifndef USE_WS_PREFIX
292 #define IPPORT_ECHO 7
293 #define IPPORT_DISCARD 9
294 #define IPPORT_SYSTAT 11
295 #define IPPORT_DAYTIME 13
296 #define IPPORT_NETSTAT 15
297 #define IPPORT_FTP 21
298 #define IPPORT_TELNET 23
299 #define IPPORT_SMTP 25
300 #define IPPORT_TIMESERVER 37
301 #define IPPORT_NAMESERVER 42
302 #define IPPORT_WHOIS 43
303 #define IPPORT_MTP 57
304 #define IPPORT_TFTP 69
305 #define IPPORT_RJE 77
306 #define IPPORT_FINGER 79
307 #define IPPORT_TTYLINK 87
308 #define IPPORT_SUPDUP 95
309 #define IPPORT_EXECSERVER 512
310 #define IPPORT_LOGINSERVER 513
311 #define IPPORT_CMDSERVER 514
312 #define IPPORT_EFSSERVER 520
313 #define IPPORT_BIFFUDP 512
314 #define IPPORT_WHOSERVER 513
315 #define IPPORT_ROUTESERVER 520
316 #define IPPORT_RESERVED 1024
317 #else /* USE_WS_PREFIX */
318 #define WS_IPPORT_ECHO 7
319 #define WS_IPPORT_DISCARD 9
320 #define WS_IPPORT_SYSTAT 11
321 #define WS_IPPORT_DAYTIME 13
322 #define WS_IPPORT_NETSTAT 15
323 #define WS_IPPORT_FTP 21
324 #define WS_IPPORT_TELNET 23
325 #define WS_IPPORT_SMTP 25
326 #define WS_IPPORT_TIMESERVER 37
327 #define WS_IPPORT_NAMESERVER 42
328 #define WS_IPPORT_WHOIS 43
329 #define WS_IPPORT_MTP 57
330 #define WS_IPPORT_TFTP 69
331 #define WS_IPPORT_RJE 77
332 #define WS_IPPORT_FINGER 79
333 #define WS_IPPORT_TTYLINK 87
334 #define WS_IPPORT_SUPDUP 95
335 #define WS_IPPORT_EXECSERVER 512
336 #define WS_IPPORT_LOGINSERVER 513
337 #define WS_IPPORT_CMDSERVER 514
338 #define WS_IPPORT_EFSSERVER 520
339 #define WS_IPPORT_BIFFUDP 512
340 #define WS_IPPORT_WHOSERVER 513
341 #define WS_IPPORT_ROUTESERVER 520
342 #define WS_IPPORT_RESERVED 1024
343 #endif /* USE_WS_PREFIX */
345 typedef struct WS(servent
)
347 char* s_name
; /* official service name */
348 char** s_aliases
; /* alias list */
349 short s_port
; /* port # */
350 char* s_proto
; /* protocol to use */
351 } SERVENT
, *PSERVENT
, *LPSERVENT
;
359 typedef struct WS(hostent
)
361 char* h_name
; /* official name of host */
362 char** h_aliases
; /* alias list */
363 short h_addrtype
; /* host address type */
364 short h_length
; /* length of address */
365 char** h_addr_list
; /* list of addresses from name server */
366 #define h_addr h_addr_list[0] /* address, for backward compat */
367 } HOSTENT
, *PHOSTENT
, *LPHOSTENT
;
374 typedef UINT_PTR SOCKET
;
377 * This is used instead of -1, since the
378 * SOCKET type is unsigned.
380 #define INVALID_SOCKET (~0)
381 #define SOCKET_ERROR (-1)
383 typedef struct WS(sockaddr
)
387 } SOCKADDR
, *PSOCKADDR
, *LPSOCKADDR
;
389 typedef struct WS(linger
)
391 u_short l_onoff
; /* option on/off */
392 u_short l_linger
; /* linger time */
393 } LINGER
, *PLINGER
, *LPLINGER
;
399 #ifdef WS_DEFINE_SELECT
400 /* Define our own version of select and the associated types and macros */
402 # ifndef USE_WS_PREFIX
404 # define FD_SETSIZE 64
407 # ifndef WS_FD_SETSIZE
408 # define WS_FD_SETSIZE 64
412 typedef struct WS(fd_set
)
414 u_int fd_count
; /* how many are SET? */
415 # ifndef USE_WS_PREFIX
416 SOCKET fd_array
[FD_SETSIZE
]; /* an array of SOCKETs */
418 SOCKET fd_array
[WS_FD_SETSIZE
];/* an array of SOCKETs */
420 } WS(fd_set
), FD_SET
, *PFD_SET
, *LPFD_SET
;
422 typedef struct WS(timeval
)
424 long tv_sec
; /* seconds */
425 long tv_usec
; /* and microseconds */
426 } TIMEVAL
, *PTIMEVAL
, *LPTIMEVAL
;
428 #define WINE_FD_CLR(fd, set, cast) do { \
430 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
432 if (((cast*)(set))->fd_array[__i] == fd) \
434 while (__i < ((cast*)(set))->fd_count-1) \
436 ((cast*)(set))->fd_array[__i] = \
437 ((cast*)(set))->fd_array[__i+1]; \
440 ((cast*)(set))->fd_count--; \
445 #define __WS_FD_SET1(fd, set, cast) do { \
446 if (((cast*)(set))->fd_count < FD_SETSIZE) \
447 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
449 /* This version checks if the filedesc is already in the list, and appends it
450 * only if it's not the case
452 #define __WS_FD_SET2(fd, set, cast) do { \
454 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
456 if (((cast*)(set))->fd_array[__i]==(fd)) \
459 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
461 ((cast*)(set))->fd_count++; \
462 ((cast*)(set))->fd_array[__i]=(fd);\
466 #ifndef __WINE_WINSOCK2__
467 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
469 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
472 #ifndef USE_WS_PREFIX
473 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
474 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
475 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
476 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
478 #define WS_FD_CLR(fd, set) WINE_FD_CLR((fd),(set), WS_fd_set)
479 #define WS_FD_SET(fd, set) WINE_FD_SET((fd),(set), WS_fd_set)
480 #define WS_FD_ZERO(set) ((WS_fd_set*)(set))->fd_count=0)
481 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
484 u_long WINAPI
WS(htonl
)(u_long
);
485 u_short WINAPI
WS(htons
)(u_short
);
486 u_long WINAPI
WS(ntohl
)(u_long
);
487 u_short WINAPI
WS(ntohs
)(u_short
);
489 #endif /* WS_DEFINE_SELECT */
493 * Internet address (old style... should be updated)
496 #ifndef USE_WS_PREFIX
497 #define IN_CLASSA_NSHIFT 24
498 #define IN_CLASSA_MAX 128
499 #define IN_CLASSA_NET 0xff000000
500 #define IN_CLASSA_HOST 0x00ffffff
501 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
502 #define IN_CLASSB_NSHIFT 16
503 #define IN_CLASSB_MAX 65536
504 #define IN_CLASSB_NET 0xffff0000
505 #define IN_CLASSB_HOST 0x0000ffff
506 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
507 #define IN_CLASSC_NSHIFT 8
508 #define IN_CLASSC_NET 0xffffff00
509 #define IN_CLASSC_HOST 0x000000ff
510 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
512 #define WS_IN_CLASSA_NSHIFT 24
513 #define WS_IN_CLASSA_MAX 128
514 #define WS_IN_CLASSA_NET 0xff000000
515 #define WS_IN_CLASSA_HOST 0x00ffffff
516 #define WS_IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
517 #define WS_IN_CLASSB_NSHIFT 16
518 #define WS_IN_CLASSB_MAX 65536
519 #define WS_IN_CLASSB_NET 0xffff0000
520 #define WS_IN_CLASSB_HOST 0x0000ffff
521 #define WS_IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
522 #define WS_IN_CLASSC_NSHIFT 8
523 #define WS_IN_CLASSC_NET 0xffffff00
524 #define WS_IN_CLASSC_HOST 0x000000ff
525 #define WS_IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
526 #endif /* USE_WS_PREFIX */
528 #ifndef USE_WS_PREFIX
529 #define INADDR_ANY (u_long)0x00000000
530 #define INADDR_LOOPBACK 0x7f000001
531 #define INADDR_BROADCAST (u_long)0xffffffff
532 #define INADDR_NONE 0xffffffff
534 #define WS_INADDR_ANY (u_long)0x00000000
535 #define WS_INADDR_LOOPBACK 0x7f000001
536 #define WS_INADDR_BROADCAST (u_long)0xffffffff
537 #define WS_INADDR_NONE 0xffffffff
538 #endif /* USE_WS_PREFIX */
540 typedef struct WS(in_addr
)
544 u_char s_b1
,s_b2
,s_b3
,s_b4
;
551 #ifndef USE_WS_PREFIX
552 #define s_addr S_un.S_addr
553 #define s_host S_un.S_un_b.s_b2
554 #define s_net S_un.S_un_b.s_b1
555 #define s_imp S_un.S_un_w.s_w2
556 #define s_impno S_un.S_un_b.s_b4
557 #define s_lh S_un.S_un_b.s_b3
559 #define WS_s_addr S_un.S_addr
560 #define WS_s_host S_un.S_un_b.s_b2
561 #define WS_s_net S_un.S_un_b.s_b1
562 #define WS_s_imp S_un.S_un_w.s_w2
563 #define WS_s_impno S_un.S_un_b.s_b4
564 #define WS_s_lh S_un.S_un_b.s_b3
565 #endif /* USE_WS_PREFIX */
566 } IN_ADDR
, *PIN_ADDR
, *LPIN_ADDR
;
568 typedef struct WS(sockaddr_in
)
572 struct WS(in_addr
) sin_addr
;
574 } SOCKADDR_IN
, *PSOCKADDR_IN
, *LPSOCKADDR_IN
;
580 #define WSADESCRIPTION_LEN 256
581 #define WSASYS_STATUS_LEN 128
583 typedef struct WS(WSAData
)
587 char szDescription
[WSADESCRIPTION_LEN
+1];
588 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
592 } WSADATA
, *LPWSADATA
;
599 #ifndef USE_WS_PREFIX
600 #define SOL_SOCKET 0xffff
601 #define SO_DEBUG 0x0001
602 #define SO_ACCEPTCONN 0x0002
603 #define SO_REUSEADDR 0x0004
604 #define SO_KEEPALIVE 0x0008
605 #define SO_DONTROUTE 0x0010
606 #define SO_BROADCAST 0x0020
607 #define SO_USELOOPBACK 0x0040
608 #define SO_LINGER 0x0080
609 #define SO_OOBINLINE 0x0100
610 #define SO_DONTLINGER (u_int)(~SO_LINGER)
611 #define SO_SNDBUF 0x1001
612 #define SO_RCVBUF 0x1002
613 #define SO_SNDLOWAT 0x1003
614 #define SO_RCVLOWAT 0x1004
615 #define SO_SNDTIMEO 0x1005
616 #define SO_RCVTIMEO 0x1006
617 #define SO_ERROR 0x1007
618 #define SO_TYPE 0x1008
621 #define IOCPARM_MASK 0x7f
622 #define IOC_VOID 0x20000000
623 #define IOC_OUT 0x40000000
624 #define IOC_IN 0x80000000
625 #define IOC_INOUT (IOC_IN|IOC_OUT)
627 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
628 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
629 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
633 #define WS_SOL_SOCKET 0xffff
634 #define WS_SO_DEBUG 0x0001
635 #define WS_SO_ACCEPTCONN 0x0002
636 #define WS_SO_REUSEADDR 0x0004
637 #define WS_SO_KEEPALIVE 0x0008
638 #define WS_SO_DONTROUTE 0x0010
639 #define WS_SO_BROADCAST 0x0020
640 #define WS_SO_USELOOPBACK 0x0040
641 #define WS_SO_LINGER 0x0080
642 #define WS_SO_OOBINLINE 0x0100
643 #define WS_SO_DONTLINGER (u_int)(~WS_SO_LINGER)
644 #define WS_SO_SNDBUF 0x1001
645 #define WS_SO_RCVBUF 0x1002
646 #define WS_SO_SNDLOWAT 0x1003
647 #define WS_SO_RCVLOWAT 0x1004
648 #define WS_SO_SNDTIMEO 0x1005
649 #define WS_SO_RCVTIMEO 0x1006
650 #define WS_SO_ERROR 0x1007
651 #define WS_SO_TYPE 0x1008
653 #define WS_IOCPARM_MASK 0x7f
654 #define WS_IOC_VOID 0x20000000
655 #define WS_IOC_OUT 0x40000000
656 #define WS_IOC_IN 0x80000000
657 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
659 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
660 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
661 #define WS__IOW(x,y,t) (WS_IOC_IN|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
665 /* IPPROTO_TCP options */
666 #ifndef USE_WS_PREFIX
667 #define TCP_NODELAY 1
669 #define WS_TCP_NODELAY 1
672 /* IPPROTO_IP options */
673 #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
674 # ifndef USE_WS_PREFIX
675 # define IP_OPTIONS 1
676 # define IP_MULTICAST_IF 2
677 # define IP_MULTICAST_TTL 3
678 # define IP_MULTICAST_LOOP 4
679 # define IP_ADD_MEMBERSHIP 5
680 # define IP_DROP_MEMBERSHIP 6
683 # define IP_DONTFRAGMENT 9
685 # define WS_IP_OPTIONS 1
686 # define WS_IP_MULTICAST_IF 2
687 # define WS_IP_MULTICAST_TTL 3
688 # define WS_IP_MULTICAST_LOOP 4
689 # define WS_IP_ADD_MEMBERSHIP 5
690 # define WS_IP_DROP_MEMBERSHIP 6
693 # define WS_IP_DONTFRAGMENT 9
699 * Socket I/O flags (supported by spec 1.1)
701 #ifndef USE_WS_PREFIX
702 #define FIONREAD _IOR('f', 127, u_long)
703 #define FIONBIO _IOW('f', 126, u_long)
704 #define SIOCATMARK _IOR('s', 7, u_long)
706 #define WS_FIONREAD WS__IOR('f', 127, u_long)
707 #define WS_FIONBIO WS__IOW('f', 126, u_long)
708 #define WS_SIOCATMARK WS__IOR('s', 7, u_long)
712 * Maximum queue length specifiable by listen.
714 #ifndef USE_WS_PREFIX
717 #define MSG_OOB 0x0001
718 #define MSG_PEEK 0x0002
719 #define MSG_DONTROUTE 0x0004
720 #define MSG_MAXIOVLEN 0x000a
721 #define MSG_PARTIAL 0x8000
722 #else /* USE_WS_PREFIX */
723 #define WS_SOMAXCONN 5
725 #define WS_MSG_OOB 0x0001
726 #define WS_MSG_PEEK 0x0002
727 #define WS_MSG_DONTROUTE 0x0004
728 #define WS_MSG_MAXIOVLEN 0x000a
729 #define WS_MSG_PARTIAL 0x8000
730 #endif /* USE_WS_PREFIX */
733 * Define constant based on rfc883, used by gethostbyxxxx() calls.
735 #ifndef USE_WS_PREFIX
736 #define MAXGETHOSTSTRUCT 1024
738 #define MAXGETHOSTSTRUCT 1024
743 * Define flags to be used with the WSAAsyncSelect() call.
745 #define FD_READ 0x00000001
746 #define FD_WRITE 0x00000002
747 #define FD_OOB 0x00000004
748 #define FD_ACCEPT 0x00000008
749 #define FD_CONNECT 0x00000010
750 #define FD_CLOSE 0x00000020
752 /* internal per-socket flags */
754 #define FD_WINE_LISTENING 0x10000000
755 #define FD_WINE_NONBLOCKING 0x20000000
756 #define FD_WINE_CONNECTED 0x40000000
757 #define FD_WINE_RAW 0x80000000
758 #define FD_WINE_INTERNAL 0xFFFF0000
762 * All Windows Sockets error constants are biased by WSABASEERR from
765 #define WSABASEERR 10000
767 * Windows Sockets definitions of regular Microsoft C error constants
769 #define WSAEINTR (WSABASEERR+4)
770 #define WSAEBADF (WSABASEERR+9)
771 #define WSAEACCES (WSABASEERR+13)
772 #define WSAEFAULT (WSABASEERR+14)
773 #define WSAEINVAL (WSABASEERR+22)
774 #define WSAEMFILE (WSABASEERR+24)
777 * Windows Sockets definitions of regular Berkeley error constants
779 #define WSAEWOULDBLOCK (WSABASEERR+35)
780 #define WSAEINPROGRESS (WSABASEERR+36)
781 #define WSAEALREADY (WSABASEERR+37)
782 #define WSAENOTSOCK (WSABASEERR+38)
783 #define WSAEDESTADDRREQ (WSABASEERR+39)
784 #define WSAEMSGSIZE (WSABASEERR+40)
785 #define WSAEPROTOTYPE (WSABASEERR+41)
786 #define WSAENOPROTOOPT (WSABASEERR+42)
787 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
788 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
789 #define WSAEOPNOTSUPP (WSABASEERR+45)
790 #define WSAEPFNOSUPPORT (WSABASEERR+46)
791 #define WSAEAFNOSUPPORT (WSABASEERR+47)
792 #define WSAEADDRINUSE (WSABASEERR+48)
793 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
794 #define WSAENETDOWN (WSABASEERR+50)
795 #define WSAENETUNREACH (WSABASEERR+51)
796 #define WSAENETRESET (WSABASEERR+52)
797 #define WSAECONNABORTED (WSABASEERR+53)
798 #define WSAECONNRESET (WSABASEERR+54)
799 #define WSAENOBUFS (WSABASEERR+55)
800 #define WSAEISCONN (WSABASEERR+56)
801 #define WSAENOTCONN (WSABASEERR+57)
802 #define WSAESHUTDOWN (WSABASEERR+58)
803 #define WSAETOOMANYREFS (WSABASEERR+59)
804 #define WSAETIMEDOUT (WSABASEERR+60)
805 #define WSAECONNREFUSED (WSABASEERR+61)
806 #define WSAELOOP (WSABASEERR+62)
807 #define WSAENAMETOOLONG (WSABASEERR+63)
808 #define WSAEHOSTDOWN (WSABASEERR+64)
809 #define WSAEHOSTUNREACH (WSABASEERR+65)
810 #define WSAENOTEMPTY (WSABASEERR+66)
811 #define WSAEPROCLIM (WSABASEERR+67)
812 #define WSAEUSERS (WSABASEERR+68)
813 #define WSAEDQUOT (WSABASEERR+69)
814 #define WSAESTALE (WSABASEERR+70)
815 #define WSAEREMOTE (WSABASEERR+71)
816 #define WSAEDISCON (WSABASEERR+101)
819 * Extended Windows Sockets error constant definitions
821 #define WSASYSNOTREADY (WSABASEERR+91)
822 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
823 #define WSANOTINITIALISED (WSABASEERR+93)
826 * Error return codes from gethostbyname() and gethostbyaddr()
827 * (when using the resolver). Note that these errors are
828 * retrieved via WSAGetLastError() and must therefore follow
829 * the rules for avoiding clashes with error numbers from
830 * specific implementations or language run-time systems.
831 * For this reason the codes are based at WSABASEERR+1001.
832 * Note also that [WSA]NO_ADDRESS is defined only for
833 * compatibility purposes.
836 #ifndef USE_WS_PREFIX
837 #define h_errno WSAGetLastError()
839 #define WS_h_errno WSAGetLastError()
842 /* Authoritative Answer: Host not found */
843 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
845 /* Non-Authoritative: Host not found, or SERVERFAIL */
846 #define WSATRY_AGAIN (WSABASEERR+1002)
848 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
849 #define WSANO_RECOVERY (WSABASEERR+1003)
851 /* Valid name, no data record of requested type */
852 #define WSANO_DATA (WSABASEERR+1004)
854 /* no address, look for MX record */
855 #define WSANO_ADDRESS WSANO_DATA
857 #ifndef USE_WS_PREFIX
858 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
859 #define TRY_AGAIN WSATRY_AGAIN
860 #define NO_RECOVERY WSANO_RECOVERY
861 #define NO_DATA WSANO_DATA
862 #define NO_ADDRESS WSANO_ADDRESS
863 #endif /* USE_WS_PREFIX */
868 * Windows message parameter composition and decomposition
873 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
874 * when constructing the response to a WSAAsyncGetXByY() routine.
876 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
878 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
879 * when constructing the response to WSAAsyncSelect().
881 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
883 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
884 * to extract the buffer length from the lParam in the response
887 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
889 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
890 * to extract the error code from the lParam in the response
893 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
895 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
896 * to extract the event code from the lParam in the response
897 * to a WSAAsyncSelect().
899 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
901 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
902 * to extract the error code from the lParam in the response
903 * to a WSAAsyncSelect().
905 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
912 * Remember to keep this section in sync with the
913 * "Winsock Function Typedefs" section in winsock2.h.
915 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
916 HANDLE WINAPI
WSAAsyncGetHostByAddr(HWND
,u_int
,const char*,int,int,char*,int);
917 HANDLE WINAPI
WSAAsyncGetHostByName(HWND
,u_int
,const char*,char*,int);
918 HANDLE WINAPI
WSAAsyncGetProtoByName(HWND
,u_int
,const char*,char*,int);
919 HANDLE WINAPI
WSAAsyncGetProtoByNumber(HWND
,u_int
,int,char*,int);
920 HANDLE WINAPI
WSAAsyncGetServByName(HWND
,u_int
,const char*,const char*,char*,int);
921 HANDLE WINAPI
WSAAsyncGetServByPort(HWND
,u_int
,int,const char*,char*,int);
922 int WINAPI
WSAAsyncSelect(SOCKET
,HWND
,u_int
,long);
923 int WINAPI
WSACancelAsyncRequest(HANDLE
);
924 int WINAPI
WSACancelBlockingCall(void);
925 int WINAPI
WSACleanup(void);
926 int WINAPI
WSAGetLastError(void);
927 BOOL WINAPI
WSAIsBlocking(void);
928 FARPROC WINAPI
WSASetBlockingHook(FARPROC
);
929 void WINAPI
WSASetLastError(int);
930 int WINAPI
WSAStartup(WORD
,LPWSADATA
);
931 int WINAPI
WSAUnhookBlockingHook(void);
933 SOCKET WINAPI
WS(accept
)(SOCKET
,struct WS(sockaddr
)*,int*);
934 int WINAPI
WS(bind
)(SOCKET
,const struct WS(sockaddr
)*,int);
935 int WINAPI
WS(closesocket
)(SOCKET
);
936 int WINAPI
WS(connect
)(SOCKET
,const struct WS(sockaddr
)*,int);
937 struct WS(hostent
)* WINAPI
WS(gethostbyaddr
)(const char*,int,int);
938 struct WS(hostent
)* WINAPI
WS(gethostbyname
)(const char*);
939 /* gethostname not defined because of conflicts with unistd.h */
940 int WINAPI
WS(getpeername
)(SOCKET
,struct WS(sockaddr
)*,int*);
941 struct WS(protoent
)* WINAPI
WS(getprotobyname
)(const char*);
942 struct WS(protoent
)* WINAPI
WS(getprotobynumber
)(int);
943 #ifdef WS_DEFINE_SELECT
944 int WINAPI
WS(select
)(int,WS(fd_set
)*,WS(fd_set
)*,WS(fd_set
)*,const struct WS(timeval
)*);
946 struct WS(servent
)* WINAPI
WS(getservbyname
)(const char*,const char*);
947 struct WS(servent
)* WINAPI
WS(getservbyport
)(int,const char*);
948 int WINAPI
WS(getsockname
)(SOCKET
,struct WS(sockaddr
)*,int*);
949 int WINAPI
WS(getsockopt
)(SOCKET
,int,int,char*,int*);
950 unsigned long WINAPI
WS(inet_addr
)(const char*);
951 char* WINAPI
WS(inet_ntoa
)(struct WS(in_addr
));
952 int WINAPI
WS(ioctlsocket
)(SOCKET
,long,u_long
*);
953 int WINAPI
WS(listen
)(SOCKET
,int);
954 int WINAPI
WS(recv
)(SOCKET
,char*,int,int);
955 int WINAPI
WS(recvfrom
)(SOCKET
,char*,int,int,struct WS(sockaddr
)*,int*);
956 int WINAPI
WS(send
)(SOCKET
,const char*,int,int);
957 int WINAPI
WS(sendto
)(SOCKET
,const char*,int,int,const struct WS(sockaddr
)*,int);
958 int WINAPI
WS(setsockopt
)(SOCKET
,int,int,const char*,int);
959 int WINAPI
WS(shutdown
)(SOCKET
,int);
960 SOCKET WINAPI
WS(socket
)(int,int,int);
962 #if defined(__WINESRC__) || !defined(__WINE_WINSOCK2__)
963 /* Stuff specific to winsock.h */
967 #endif /* __WINE_WINSOCK2__ */
968 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
977 #ifndef __WINE_WINSOCK2__
979 #undef WS_API_PROTOTYPES
980 #undef WS_API_TYPEDEFS
983 #endif /* _WINSOCKAPI_ */