user32/tests: Account for some messages from dual-monitor setups.
[wine.git] / include / winsock.h
blob350e5636f8185498a5694a5796ae6a31afa8013d
1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
4 * specification.
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
23 #ifdef __WINESRC__
24 # error Please use winsock2 in Wine
25 #endif
27 #ifndef __WINE_WINSOCKAPI_STDLIB_H
28 #define __WINE_WINSOCKAPI_STDLIB_H
31 * This section defines the items that conflict with the Unix headers.
33 #ifndef USE_WS_PREFIX
34 /* We are not using the WS_ prefix we risk getting conflicts for
35 * everything related to select.
37 # ifdef FD_CLR
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
42 * inadvertently.
44 # include <sys/types.h>
45 # undef FD_SETSIZE
46 # undef FD_CLR
47 # undef FD_SET
48 # undef FD_ZERO
49 # undef FD_ISSET
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>
62 # include <time.h>
63 # include <stdlib.h>
64 # undef fd_set
65 # undef FD_SETSIZE
66 # undef FD_CLR
67 # undef FD_SET
68 # undef FD_ZERO
69 # undef FD_ISSET
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
72 # else /* FD_CLR */
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>
83 # include <time.h>
84 # include <stdlib.h>
85 # undef fd_set
86 # undef timeval
87 # undef select
88 # undef socklen_t
89 # undef u_long
90 # undef FD_SETSIZE
91 # undef FD_CLR
92 # undef FD_SET
93 # undef FD_ZERO
94 # undef FD_ISSET
95 # undef _TIMEVAL_DEFINED
97 # define WS_DEFINE_SELECT
98 # endif /* FD_CLR */
100 #else
101 # define WS_DEFINE_SELECT
102 # include <sys/types.h>
103 # include <stdlib.h>
104 #endif /* !USE_WS_PREFIX */
106 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
108 #include <windows.h>
110 #ifndef _WINSOCKAPI_
111 #define _WINSOCKAPI_
113 #include <inaddr.h>
115 #ifndef WINSOCK_API_LINKAGE
116 #ifdef _WS2_32_
117 # define WINSOCK_API_LINKAGE
118 #else
119 # define WINSOCK_API_LINKAGE DECLSPEC_IMPORT
120 #endif
121 #endif
123 #ifdef USE_WS_PREFIX
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
135 #else
136 #define u_long ULONG /* make sure we don't use the system u_long */
137 #endif
139 #ifdef USE_WS_PREFIX
140 # define WS(x) WS_##x
141 #else
142 # define WS(x) x
143 #endif
145 #ifdef __cplusplus
146 extern "C" {
147 #endif /* defined(__cplusplus) */
150 * Address families
152 #ifndef USE_WS_PREFIX
153 #define AF_UNSPEC 0
154 #define AF_UNIX 1
155 #define AF_INET 2
156 #define AF_IMPLINK 3
157 #define AF_PUP 4
158 #define AF_CHAOS 5
159 #define AF_NS 6
160 #define AF_IPX AF_NS
161 #define AF_ISO 7
162 #define AF_OSI AF_ISO
163 #define AF_ECMA 8
164 #define AF_DATAKIT 9
165 #define AF_CCITT 10
166 #define AF_SNA 11
167 #define AF_DECnet 12
168 #define AF_DLI 13
169 #define AF_LAT 14
170 #define AF_HYLINK 15
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
176 #define AF_BAN 21
177 #define AF_MAX 22
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
184 #define PF_NS AF_NS
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
204 #define WS_AF_UNIX 1
205 #define WS_AF_INET 2
206 #define WS_AF_IMPLINK 3
207 #define WS_AF_PUP 4
208 #define WS_AF_CHAOS 5
209 #define WS_AF_NS 6
210 #define WS_AF_IPX WS_AF_NS
211 #define WS_AF_ISO 7
212 #define WS_AF_OSI AF_ISO
213 #define WS_AF_ECMA 8
214 #define WS_AF_DATAKIT 9
215 #define WS_AF_CCITT 10
216 #define WS_AF_SNA 11
217 #define WS_AF_DECnet 12
218 #define WS_AF_DLI 13
219 #define WS_AF_LAT 14
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
226 #define WS_AF_BAN 21
227 #define WS_AF_MAX 22
228 #endif /* USE_WS_PREFIX */
231 * Types
233 #ifndef USE_WS_PREFIX
234 #define SOCK_STREAM 1
235 #define SOCK_DGRAM 2
236 #define SOCK_RAW 3
237 #define SOCK_RDM 4
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 */
249 * Protocols
251 #ifndef USE_WS_PREFIX
252 #define IPPROTO_IP 0
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)
277 char* p_name;
278 char** p_aliases;
279 short p_proto;
280 } PROTOENT, *PPROTOENT, *LPPROTOENT;
285 * Networks
287 struct WS(netent)
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 # */
297 * Services
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 */
357 #ifdef _WIN64
358 char* s_proto; /* protocol to use */
359 short s_port; /* port # */
360 #else
361 short s_port; /* port # */
362 char* s_proto; /* protocol to use */
363 #endif
364 } SERVENT, *PSERVENT, *LPSERVENT;
369 * Hosts
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;
384 * Sockets
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;
399 char sa_data[14];
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;
409 * Select
412 #ifdef WS_DEFINE_SELECT
413 /* Define our own version of select and the associated types and macros */
415 # ifndef USE_WS_PREFIX
416 # ifndef FD_SETSIZE
417 # define FD_SETSIZE 64
418 # endif
419 # else
420 # ifndef WS_FD_SETSIZE
421 # define WS_FD_SETSIZE 64
422 # endif
423 # endif
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 */
430 # else
431 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
432 # endif
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;
442 #endif
444 #define __WS_FD_CLR(fd, set, cast) do { \
445 unsigned int __i; \
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]; \
454 __i++; \
456 ((cast*)(set))->fd_count--; \
457 break; \
460 } while(0)
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); \
465 } while(0)
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))
472 #else
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))
477 #endif
479 WINSOCK_API_LINKAGE int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
481 #endif /* WS_DEFINE_SELECT */
483 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
484 #ifndef USE_WS_PREFIX
486 #undef htonl
487 #undef htons
488 #undef ntohl
489 #undef ntohs
491 #ifdef WORDS_BIGENDIAN
493 static inline u_short __wine_ushort_noop(u_short s)
495 return s;
497 static inline ULONG __wine_ulong_noop(ULONG l)
499 return l;
501 #define htonl __wine_ulong_noop
502 #define htons __wine_ushort_noop
503 #define ntohl __wine_ulong_noop
504 #define ntohs __wine_ushort_noop
506 #else /* WORDS_BIGENDIAN */
508 static inline u_short __wine_ushort_swap(u_short s)
510 return (s >> 8) | (s << 8);
512 static inline ULONG __wine_ulong_swap(ULONG l)
514 return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
516 #define htonl __wine_ulong_swap
517 #define htons __wine_ushort_swap
518 #define ntohl __wine_ulong_swap
519 #define ntohs __wine_ushort_swap
521 #endif /* WORDS_BIGENDIAN */
523 #endif /* USE_WS_PREFIX */
526 * Internet address (old style... should be updated)
529 #ifndef USE_WS_PREFIX
530 #define IN_CLASSA_NSHIFT 24
531 #define IN_CLASSA_MAX 128
532 #define IN_CLASSA_NET 0xff000000
533 #define IN_CLASSA_HOST 0x00ffffff
534 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
535 #define IN_CLASSB_NSHIFT 16
536 #define IN_CLASSB_MAX 65536
537 #define IN_CLASSB_NET 0xffff0000
538 #define IN_CLASSB_HOST 0x0000ffff
539 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
540 #define IN_CLASSC_NSHIFT 8
541 #define IN_CLASSC_NET 0xffffff00
542 #define IN_CLASSC_HOST 0x000000ff
543 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
544 #else
545 #define WS_IN_CLASSA_NSHIFT 24
546 #define WS_IN_CLASSA_MAX 128
547 #define WS_IN_CLASSA_NET 0xff000000
548 #define WS_IN_CLASSA_HOST 0x00ffffff
549 #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
550 #define WS_IN_CLASSB_NSHIFT 16
551 #define WS_IN_CLASSB_MAX 65536
552 #define WS_IN_CLASSB_NET 0xffff0000
553 #define WS_IN_CLASSB_HOST 0x0000ffff
554 #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
555 #define WS_IN_CLASSC_NSHIFT 8
556 #define WS_IN_CLASSC_NET 0xffffff00
557 #define WS_IN_CLASSC_HOST 0x000000ff
558 #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
559 #endif /* USE_WS_PREFIX */
561 #ifndef USE_WS_PREFIX
562 #define INADDR_ANY ((ULONG)0x00000000)
563 #define INADDR_LOOPBACK 0x7f000001
564 #define INADDR_BROADCAST ((ULONG)0xffffffff)
565 #define INADDR_NONE 0xffffffff
566 #else
567 #define WS_INADDR_ANY ((ULONG)0x00000000)
568 #define WS_INADDR_LOOPBACK 0x7f000001
569 #define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
570 #define WS_INADDR_NONE 0xffffffff
571 #endif /* USE_WS_PREFIX */
573 typedef struct WS(sockaddr_in)
575 short sin_family;
576 WS(u_short) sin_port;
577 struct WS(in_addr) sin_addr;
578 char sin_zero[8];
579 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
582 * Multicast group information
585 struct WS(ip_mreq)
587 struct WS(in_addr) imr_multiaddr;
588 struct WS(in_addr) imr_interface;
592 * WSAStartup
594 #define WSADESCRIPTION_LEN 256
595 #define WSASYS_STATUS_LEN 128
597 typedef struct WS(WSAData)
599 WORD wVersion;
600 WORD wHighVersion;
601 #ifdef _WIN64
602 WORD iMaxSockets;
603 WORD iMaxUdpDg;
604 char *lpVendorInfo;
605 char szDescription[WSADESCRIPTION_LEN+1];
606 char szSystemStatus[WSASYS_STATUS_LEN+1];
607 #else
608 char szDescription[WSADESCRIPTION_LEN+1];
609 char szSystemStatus[WSASYS_STATUS_LEN+1];
610 WORD iMaxSockets;
611 WORD iMaxUdpDg;
612 char *lpVendorInfo;
613 #endif
614 } WSADATA, *LPWSADATA;
619 * {get,set}sockopt
621 #ifndef USE_WS_PREFIX
622 #define SOL_SOCKET 0xffff
623 #define SO_DEBUG 0x0001
624 #define SO_ACCEPTCONN 0x0002
625 #define SO_REUSEADDR 0x0004
626 #define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
627 #define SO_KEEPALIVE 0x0008
628 #define SO_DONTROUTE 0x0010
629 #define SO_BROADCAST 0x0020
630 #define SO_USELOOPBACK 0x0040
631 #define SO_LINGER 0x0080
632 #define SO_OOBINLINE 0x0100
633 #define SO_DONTLINGER ((u_int)(~SO_LINGER))
634 #define SO_SNDBUF 0x1001
635 #define SO_RCVBUF 0x1002
636 #define SO_SNDLOWAT 0x1003
637 #define SO_RCVLOWAT 0x1004
638 #define SO_SNDTIMEO 0x1005
639 #define SO_RCVTIMEO 0x1006
640 #define SO_ERROR 0x1007
641 #define SO_TYPE 0x1008
643 #define IOCPARM_MASK 0x7f
644 #define IOC_VOID 0x20000000
645 #define IOC_OUT 0x40000000
646 #define IOC_IN 0x80000000
647 #define IOC_INOUT (IOC_IN|IOC_OUT)
649 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
650 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
651 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
653 #else
655 #define WS_SOL_SOCKET 0xffff
656 #define WS_SO_DEBUG 0x0001
657 #define WS_SO_ACCEPTCONN 0x0002
658 #define WS_SO_REUSEADDR 0x0004
659 #define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
660 #define WS_SO_KEEPALIVE 0x0008
661 #define WS_SO_DONTROUTE 0x0010
662 #define WS_SO_BROADCAST 0x0020
663 #define WS_SO_USELOOPBACK 0x0040
664 #define WS_SO_LINGER 0x0080
665 #define WS_SO_OOBINLINE 0x0100
666 #define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
667 #define WS_SO_SNDBUF 0x1001
668 #define WS_SO_RCVBUF 0x1002
669 #define WS_SO_SNDLOWAT 0x1003
670 #define WS_SO_RCVLOWAT 0x1004
671 #define WS_SO_SNDTIMEO 0x1005
672 #define WS_SO_RCVTIMEO 0x1006
673 #define WS_SO_ERROR 0x1007
674 #define WS_SO_TYPE 0x1008
676 #define WS_IOCPARM_MASK 0x7f
677 #define WS_IOC_VOID 0x20000000
678 #define WS_IOC_OUT 0x40000000
679 #define WS_IOC_IN 0x80000000
680 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
682 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
683 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
684 #define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
686 #endif
688 /* IPPROTO_TCP options */
689 #ifndef USE_WS_PREFIX
690 #define TCP_NODELAY 1
691 #else
692 #define WS_TCP_NODELAY 1
693 #endif
695 #ifndef USE_WS_PREFIX
696 # define IP_OPTIONS 1
697 # define IP_MULTICAST_IF 2
698 # define IP_MULTICAST_TTL 3
699 # define IP_MULTICAST_LOOP 4
700 # define IP_ADD_MEMBERSHIP 5
701 # define IP_DROP_MEMBERSHIP 6
702 # define IP_TTL 7
703 # define IP_TOS 8
704 # define IP_DONTFRAGMENT 9
705 #else
706 # define WS_IP_OPTIONS 1
707 # define WS_IP_MULTICAST_IF 2
708 # define WS_IP_MULTICAST_TTL 3
709 # define WS_IP_MULTICAST_LOOP 4
710 # define WS_IP_ADD_MEMBERSHIP 5
711 # define WS_IP_DROP_MEMBERSHIP 6
712 # define WS_IP_TTL 7
713 # define WS_IP_TOS 8
714 # define WS_IP_DONTFRAGMENT 9
715 #endif
719 * Socket I/O flags (supported by spec 1.1)
721 #ifndef USE_WS_PREFIX
722 #define FIONREAD _IOR('f', 127, ULONG)
723 #define FIONBIO _IOW('f', 126, ULONG)
724 #define FIOASYNC _IOW('f', 125, ULONG)
725 #define SIOCSHIWAT _IOW('s', 0, ULONG)
726 #define SIOCGHIWAT _IOR('s', 1, ULONG)
727 #define SIOCSLOWAT _IOW('s', 2, ULONG)
728 #define SIOCGLOWAT _IOR('s', 3, ULONG)
729 #define SIOCATMARK _IOR('s', 7, ULONG)
730 #else
731 #define WS_FIONREAD WS__IOR('f', 127, ULONG)
732 #define WS_FIONBIO WS__IOW('f', 126, ULONG)
733 #define WS_FIOASYNC WS__IOW('f', 125, ULONG)
734 #define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG)
735 #define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG)
736 #define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG)
737 #define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG)
738 #define WS_SIOCATMARK WS__IOR('s', 7, ULONG)
739 #endif
742 * Maximum queue length specifiable by listen.
744 #ifndef USE_WS_PREFIX
745 #define SOMAXCONN 5
747 #define MSG_OOB 0x0001
748 #define MSG_PEEK 0x0002
749 #define MSG_DONTROUTE 0x0004
750 #define MSG_PARTIAL 0x8000
751 #define MSG_MAXIOVLEN 16
752 #else /* USE_WS_PREFIX */
753 #define WS_SOMAXCONN 5
755 #define WS_MSG_OOB 0x0001
756 #define WS_MSG_PEEK 0x0002
757 #define WS_MSG_DONTROUTE 0x0004
758 #define WS_MSG_PARTIAL 0x8000
759 #define WS_MSG_MAXIOVLEN 16
760 #endif /* USE_WS_PREFIX */
763 * Define constant based on rfc883, used by gethostbyxxxx() calls.
765 #ifndef USE_WS_PREFIX
766 #define MAXGETHOSTSTRUCT 1024
767 #else
768 #define MAXGETHOSTSTRUCT 1024
769 #endif
773 * Define flags to be used with the WSAAsyncSelect() call.
775 #define FD_READ 0x00000001
776 #define FD_WRITE 0x00000002
777 #define FD_OOB 0x00000004
778 #define FD_ACCEPT 0x00000008
779 #define FD_CONNECT 0x00000010
780 #define FD_CLOSE 0x00000020
783 * All Windows Sockets error constants are biased by WSABASEERR from
784 * the "normal". They are also defined in winerror.h.
786 #define WSABASEERR 10000
788 * Windows Sockets definitions of regular Microsoft C error constants
790 #define WSAEINTR (WSABASEERR+4)
791 #define WSAEBADF (WSABASEERR+9)
792 #define WSAEACCES (WSABASEERR+13)
793 #define WSAEFAULT (WSABASEERR+14)
794 #define WSAEINVAL (WSABASEERR+22)
795 #define WSAEMFILE (WSABASEERR+24)
798 * Windows Sockets definitions of regular Berkeley error constants
800 #define WSAEWOULDBLOCK (WSABASEERR+35)
801 #define WSAEINPROGRESS (WSABASEERR+36)
802 #define WSAEALREADY (WSABASEERR+37)
803 #define WSAENOTSOCK (WSABASEERR+38)
804 #define WSAEDESTADDRREQ (WSABASEERR+39)
805 #define WSAEMSGSIZE (WSABASEERR+40)
806 #define WSAEPROTOTYPE (WSABASEERR+41)
807 #define WSAENOPROTOOPT (WSABASEERR+42)
808 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
809 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
810 #define WSAEOPNOTSUPP (WSABASEERR+45)
811 #define WSAEPFNOSUPPORT (WSABASEERR+46)
812 #define WSAEAFNOSUPPORT (WSABASEERR+47)
813 #define WSAEADDRINUSE (WSABASEERR+48)
814 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
815 #define WSAENETDOWN (WSABASEERR+50)
816 #define WSAENETUNREACH (WSABASEERR+51)
817 #define WSAENETRESET (WSABASEERR+52)
818 #define WSAECONNABORTED (WSABASEERR+53)
819 #define WSAECONNRESET (WSABASEERR+54)
820 #define WSAENOBUFS (WSABASEERR+55)
821 #define WSAEISCONN (WSABASEERR+56)
822 #define WSAENOTCONN (WSABASEERR+57)
823 #define WSAESHUTDOWN (WSABASEERR+58)
824 #define WSAETOOMANYREFS (WSABASEERR+59)
825 #define WSAETIMEDOUT (WSABASEERR+60)
826 #define WSAECONNREFUSED (WSABASEERR+61)
827 #define WSAELOOP (WSABASEERR+62)
828 #define WSAENAMETOOLONG (WSABASEERR+63)
829 #define WSAEHOSTDOWN (WSABASEERR+64)
830 #define WSAEHOSTUNREACH (WSABASEERR+65)
831 #define WSAENOTEMPTY (WSABASEERR+66)
832 #define WSAEPROCLIM (WSABASEERR+67)
833 #define WSAEUSERS (WSABASEERR+68)
834 #define WSAEDQUOT (WSABASEERR+69)
835 #define WSAESTALE (WSABASEERR+70)
836 #define WSAEREMOTE (WSABASEERR+71)
839 * Extended Windows Sockets error constant definitions
841 #define WSASYSNOTREADY (WSABASEERR+91)
842 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
843 #define WSANOTINITIALISED (WSABASEERR+93)
844 #define WSAEDISCON (WSABASEERR+101)
847 * Error return codes from gethostbyname() and gethostbyaddr()
848 * (when using the resolver). Note that these errors are
849 * retrieved via WSAGetLastError() and must therefore follow
850 * the rules for avoiding clashes with error numbers from
851 * specific implementations or language run-time systems.
852 * For this reason the codes are based at WSABASEERR+1001.
853 * Note also that [WSA]NO_ADDRESS is defined only for
854 * compatibility purposes.
857 #ifndef USE_WS_PREFIX
858 #define h_errno WSAGetLastError()
859 #else
860 #define WS_h_errno WSAGetLastError()
861 #endif
863 /* Authoritative Answer: Host not found */
864 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
866 /* Non-Authoritative: Host not found, or SERVERFAIL */
867 #define WSATRY_AGAIN (WSABASEERR+1002)
869 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
870 #define WSANO_RECOVERY (WSABASEERR+1003)
872 /* Valid name, no data record of requested type */
873 #define WSANO_DATA (WSABASEERR+1004)
875 /* no address, look for MX record */
876 #define WSANO_ADDRESS WSANO_DATA
878 #ifndef USE_WS_PREFIX
879 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
880 #define TRY_AGAIN WSATRY_AGAIN
881 #define NO_RECOVERY WSANO_RECOVERY
882 #define NO_DATA WSANO_DATA
883 #define NO_ADDRESS WSANO_ADDRESS
884 #endif /* USE_WS_PREFIX */
889 * Windows message parameter composition and decomposition
890 * macros.
894 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
895 * when constructing the response to a WSAAsyncGetXByY() routine.
897 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
899 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
900 * when constructing the response to WSAAsyncSelect().
902 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
904 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
905 * to extract the buffer length from the lParam in the response
906 * to a WSAGetXByY().
908 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
910 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
911 * to extract the error code from the lParam in the response
912 * to a WSAGetXByY().
914 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
916 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
917 * to extract the event code from the lParam in the response
918 * to a WSAAsyncSelect().
920 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
922 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
923 * to extract the error code from the lParam in the response
924 * to a WSAAsyncSelect().
926 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
931 * Prototypes
933 * Remember to keep this section in sync with the
934 * "Winsock Function Typedefs" section in winsock2.h.
936 WINSOCK_API_LINKAGE HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
937 WINSOCK_API_LINKAGE HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
938 WINSOCK_API_LINKAGE HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
939 WINSOCK_API_LINKAGE HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
940 WINSOCK_API_LINKAGE HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
941 WINSOCK_API_LINKAGE HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
942 WINSOCK_API_LINKAGE int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
943 WINSOCK_API_LINKAGE int WINAPI WSACancelAsyncRequest(HANDLE);
944 WINSOCK_API_LINKAGE int WINAPI WSACancelBlockingCall(void);
945 WINSOCK_API_LINKAGE int WINAPI WSACleanup(void);
946 WINSOCK_API_LINKAGE int WINAPI WSAGetLastError(void);
947 WINSOCK_API_LINKAGE BOOL WINAPI WSAIsBlocking(void);
948 WINSOCK_API_LINKAGE FARPROC WINAPI WSASetBlockingHook(FARPROC);
949 WINSOCK_API_LINKAGE void WINAPI WSASetLastError(int);
950 WINSOCK_API_LINKAGE int WINAPI WSAStartup(WORD,LPWSADATA);
951 WINSOCK_API_LINKAGE int WINAPI WSAUnhookBlockingHook(void);
953 WINSOCK_API_LINKAGE SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
954 WINSOCK_API_LINKAGE int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
955 WINSOCK_API_LINKAGE int WINAPI WS(closesocket)(SOCKET);
956 WINSOCK_API_LINKAGE int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
957 WINSOCK_API_LINKAGE struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
958 WINSOCK_API_LINKAGE struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
959 WINSOCK_API_LINKAGE int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
960 WINSOCK_API_LINKAGE struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
961 WINSOCK_API_LINKAGE struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
962 #ifdef WS_DEFINE_SELECT
963 WINSOCK_API_LINKAGE int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
964 #endif
965 WINSOCK_API_LINKAGE struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
966 WINSOCK_API_LINKAGE struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
967 WINSOCK_API_LINKAGE int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
968 WINSOCK_API_LINKAGE int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
969 WINSOCK_API_LINKAGE ULONG WINAPI WS(inet_addr)(const char*);
970 WINSOCK_API_LINKAGE char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
971 WINSOCK_API_LINKAGE int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
972 WINSOCK_API_LINKAGE int WINAPI WS(listen)(SOCKET,int);
973 WINSOCK_API_LINKAGE int WINAPI WS(recv)(SOCKET,char*,int,int);
974 WINSOCK_API_LINKAGE int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
975 WINSOCK_API_LINKAGE int WINAPI WS(send)(SOCKET,const char*,int,int);
976 WINSOCK_API_LINKAGE int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
977 WINSOCK_API_LINKAGE int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
978 WINSOCK_API_LINKAGE int WINAPI WS(shutdown)(SOCKET,int);
979 WINSOCK_API_LINKAGE SOCKET WINAPI WS(socket)(int,int,int);
981 #if defined(__MINGW32__) || defined (_MSC_VER) || defined(__WINE_USE_MSVCRT)
982 /* gethostname is not defined on Unix because of conflicts with unistd.h */
983 WINSOCK_API_LINKAGE int WINAPI WS(gethostname)(char*,int);
984 #endif
986 #ifdef __cplusplus
988 #endif
990 #undef WS
992 #endif /* _WINSOCKAPI_ */