dinput: Set correct object names for dials and sliders.
[wine.git] / include / winsock.h
blobb8a7a4ec4008a074b34cfb937f417a6a70d85067
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 #ifdef USE_WS_PREFIX
116 typedef unsigned char WS_u_char;
117 typedef unsigned short WS_u_short;
118 typedef unsigned int WS_u_int;
119 typedef ULONG WS_u_long;
120 #elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
121 /* MinGW doesn't define the u_xxx types */
122 typedef unsigned char u_char;
123 typedef unsigned short u_short;
124 typedef unsigned int u_int;
125 typedef ULONG u_long;
126 #define _BSDTYPES_DEFINED
127 #else
128 #define u_long ULONG /* make sure we don't use the system u_long */
129 #endif
131 #ifdef USE_WS_PREFIX
132 # define WS(x) WS_##x
133 #else
134 # define WS(x) x
135 #endif
137 #ifdef __cplusplus
138 extern "C" {
139 #endif /* defined(__cplusplus) */
142 * Address families
144 #ifndef USE_WS_PREFIX
145 #define AF_UNSPEC 0
146 #define AF_UNIX 1
147 #define AF_INET 2
148 #define AF_IMPLINK 3
149 #define AF_PUP 4
150 #define AF_CHAOS 5
151 #define AF_NS 6
152 #define AF_IPX AF_NS
153 #define AF_ISO 7
154 #define AF_OSI AF_ISO
155 #define AF_ECMA 8
156 #define AF_DATAKIT 9
157 #define AF_CCITT 10
158 #define AF_SNA 11
159 #define AF_DECnet 12
160 #define AF_DLI 13
161 #define AF_LAT 14
162 #define AF_HYLINK 15
163 #define AF_APPLETALK 16
164 #define AF_NETBIOS 17
165 #define AF_VOICEVIEW 18
166 #define AF_FIREFOX 19
167 #define AF_UNKNOWN1 20
168 #define AF_BAN 21
169 #define AF_MAX 22
170 #define PF_UNSPEC AF_UNSPEC
171 #define PF_UNIX AF_UNIX
172 #define PF_INET AF_INET
173 #define PF_IMPLINK AF_IMPLINK
174 #define PF_PUP AF_PUP
175 #define PF_CHAOS AF_CHAOS
176 #define PF_NS AF_NS
177 #define PF_IPX AF_IPX
178 #define PF_ISO AF_ISO
179 #define PF_OSI AF_OSI
180 #define PF_ECMA AF_ECMA
181 #define PF_DATAKIT AF_DATAKIT
182 #define PF_CCITT AF_CCITT
183 #define PF_SNA AF_SNA
184 #define PF_DECnet AF_DECnet
185 #define PF_DLI AF_DLI
186 #define PF_LAT AF_LAT
187 #define PF_HYLINK AF_HYLINK
188 #define PF_APPLETALK AF_APPLETALK
189 #define PF_VOICEVIEW AF_VOICEVIEW
190 #define PF_FIREFOX AF_FIREFOX
191 #define PF_UNKNOWN1 AF_UNKNOWN1
192 #define PF_BAN AF_BAN
193 #define PF_MAX AF_MAX
194 #else /* USE_WS_PREFIX */
195 #define WS_AF_UNSPEC 0
196 #define WS_AF_UNIX 1
197 #define WS_AF_INET 2
198 #define WS_AF_IMPLINK 3
199 #define WS_AF_PUP 4
200 #define WS_AF_CHAOS 5
201 #define WS_AF_NS 6
202 #define WS_AF_IPX WS_AF_NS
203 #define WS_AF_ISO 7
204 #define WS_AF_OSI AF_ISO
205 #define WS_AF_ECMA 8
206 #define WS_AF_DATAKIT 9
207 #define WS_AF_CCITT 10
208 #define WS_AF_SNA 11
209 #define WS_AF_DECnet 12
210 #define WS_AF_DLI 13
211 #define WS_AF_LAT 14
212 #define WS_AF_HYLINK 15
213 #define WS_AF_APPLETALK 16
214 #define WS_AF_NETBIOS 17
215 #define WS_AF_VOICEVIEW 18
216 #define WS_AF_FIREFOX 19
217 #define WS_AF_UNKNOWN1 20
218 #define WS_AF_BAN 21
219 #define WS_AF_MAX 22
220 #endif /* USE_WS_PREFIX */
223 * Types
225 #ifndef USE_WS_PREFIX
226 #define SOCK_STREAM 1
227 #define SOCK_DGRAM 2
228 #define SOCK_RAW 3
229 #define SOCK_RDM 4
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 */
241 * Protocols
243 #ifndef USE_WS_PREFIX
244 #define IPPROTO_IP 0
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)
269 char* p_name;
270 char** p_aliases;
271 short p_proto;
272 } PROTOENT, *PPROTOENT, *LPPROTOENT;
277 * Networks
279 struct WS(netent)
281 char* n_name; /* official name of net */
282 char** n_aliases; /* alias list */
283 short n_addrtype; /* net address type */
284 ULONG n_net; /* network # */
289 * Services
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 #ifdef _WIN64
350 char* s_proto; /* protocol to use */
351 short s_port; /* port # */
352 #else
353 short s_port; /* port # */
354 char* s_proto; /* protocol to use */
355 #endif
356 } SERVENT, *PSERVENT, *LPSERVENT;
361 * Hosts
364 typedef struct WS(hostent)
366 char* h_name; /* official name of host */
367 char** h_aliases; /* alias list */
368 short h_addrtype; /* host address type */
369 short h_length; /* length of address */
370 char** h_addr_list; /* list of addresses from name server */
371 #define h_addr h_addr_list[0] /* address, for backward compat */
372 } HOSTENT, *PHOSTENT, *LPHOSTENT;
376 * Sockets
379 typedef UINT_PTR SOCKET;
382 * This is used instead of -1, since the
383 * SOCKET type is unsigned.
385 #define INVALID_SOCKET (SOCKET)(~0)
386 #define SOCKET_ERROR (-1)
388 typedef struct WS(sockaddr)
390 WS(u_short) sa_family;
391 char sa_data[14];
392 } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
394 typedef struct WS(linger)
396 WS(u_short) l_onoff; /* option on/off */
397 WS(u_short) l_linger; /* linger time */
398 } LINGER, *PLINGER, *LPLINGER;
401 * Select
404 #ifdef WS_DEFINE_SELECT
405 /* Define our own version of select and the associated types and macros */
407 # ifndef USE_WS_PREFIX
408 # ifndef FD_SETSIZE
409 # define FD_SETSIZE 64
410 # endif
411 # else
412 # ifndef WS_FD_SETSIZE
413 # define WS_FD_SETSIZE 64
414 # endif
415 # endif
417 typedef struct WS(fd_set)
419 WS(u_int) fd_count; /* how many are SET? */
420 # ifndef USE_WS_PREFIX
421 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
422 # else
423 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
424 # endif
425 } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
427 #ifndef _TIMEVAL_DEFINED
428 #define _TIMEVAL_DEFINED
429 typedef struct WS(timeval)
431 LONG tv_sec; /* seconds */
432 LONG tv_usec; /* and microseconds */
433 } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
434 #endif
436 #define __WS_FD_CLR(fd, set, cast) do { \
437 unsigned int __i; \
438 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
440 if (((cast*)(set))->fd_array[__i] == fd) \
442 while (__i < ((cast*)(set))->fd_count-1) \
444 ((cast*)(set))->fd_array[__i] = \
445 ((cast*)(set))->fd_array[__i+1]; \
446 __i++; \
448 ((cast*)(set))->fd_count--; \
449 break; \
452 } while(0)
454 #define __WS_FD_SET(fd, set, cast) do { \
455 if (((cast*)(set))->fd_count < FD_SETSIZE) \
456 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
457 } while(0)
459 #ifndef USE_WS_PREFIX
460 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
461 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
462 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
463 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
464 #else
465 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
466 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
467 #define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
468 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
469 #endif
471 int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
473 #endif /* WS_DEFINE_SELECT */
475 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
476 #ifndef USE_WS_PREFIX
478 #undef htonl
479 #undef htons
480 #undef ntohl
481 #undef ntohs
483 #ifdef WORDS_BIGENDIAN
485 static inline u_short __wine_ushort_noop(u_short s)
487 return s;
489 static inline ULONG __wine_ulong_noop(ULONG l)
491 return l;
493 #define htonl __wine_ulong_noop
494 #define htons __wine_ushort_noop
495 #define ntohl __wine_ulong_noop
496 #define ntohs __wine_ushort_noop
498 #else /* WORDS_BIGENDIAN */
500 static inline u_short __wine_ushort_swap(u_short s)
502 return (s >> 8) | (s << 8);
504 static inline ULONG __wine_ulong_swap(ULONG l)
506 return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
508 #define htonl __wine_ulong_swap
509 #define htons __wine_ushort_swap
510 #define ntohl __wine_ulong_swap
511 #define ntohs __wine_ushort_swap
513 #endif /* WORDS_BIGENDIAN */
515 #endif /* USE_WS_PREFIX */
518 * Internet address (old style... should be updated)
521 #ifndef USE_WS_PREFIX
522 #define IN_CLASSA_NSHIFT 24
523 #define IN_CLASSA_MAX 128
524 #define IN_CLASSA_NET 0xff000000
525 #define IN_CLASSA_HOST 0x00ffffff
526 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
527 #define IN_CLASSB_NSHIFT 16
528 #define IN_CLASSB_MAX 65536
529 #define IN_CLASSB_NET 0xffff0000
530 #define IN_CLASSB_HOST 0x0000ffff
531 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
532 #define IN_CLASSC_NSHIFT 8
533 #define IN_CLASSC_NET 0xffffff00
534 #define IN_CLASSC_HOST 0x000000ff
535 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
536 #else
537 #define WS_IN_CLASSA_NSHIFT 24
538 #define WS_IN_CLASSA_MAX 128
539 #define WS_IN_CLASSA_NET 0xff000000
540 #define WS_IN_CLASSA_HOST 0x00ffffff
541 #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
542 #define WS_IN_CLASSB_NSHIFT 16
543 #define WS_IN_CLASSB_MAX 65536
544 #define WS_IN_CLASSB_NET 0xffff0000
545 #define WS_IN_CLASSB_HOST 0x0000ffff
546 #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
547 #define WS_IN_CLASSC_NSHIFT 8
548 #define WS_IN_CLASSC_NET 0xffffff00
549 #define WS_IN_CLASSC_HOST 0x000000ff
550 #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
551 #endif /* USE_WS_PREFIX */
553 #ifndef USE_WS_PREFIX
554 #define INADDR_ANY ((ULONG)0x00000000)
555 #define INADDR_LOOPBACK 0x7f000001
556 #define INADDR_BROADCAST ((ULONG)0xffffffff)
557 #define INADDR_NONE 0xffffffff
558 #else
559 #define WS_INADDR_ANY ((ULONG)0x00000000)
560 #define WS_INADDR_LOOPBACK 0x7f000001
561 #define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
562 #define WS_INADDR_NONE 0xffffffff
563 #endif /* USE_WS_PREFIX */
565 typedef struct WS(sockaddr_in)
567 short sin_family;
568 WS(u_short) sin_port;
569 struct WS(in_addr) sin_addr;
570 char sin_zero[8];
571 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
574 * Multicast group information
577 struct WS(ip_mreq)
579 struct WS(in_addr) imr_multiaddr;
580 struct WS(in_addr) imr_interface;
584 * WSAStartup
586 #define WSADESCRIPTION_LEN 256
587 #define WSASYS_STATUS_LEN 128
589 typedef struct WS(WSAData)
591 WORD wVersion;
592 WORD wHighVersion;
593 #ifdef _WIN64
594 WORD iMaxSockets;
595 WORD iMaxUdpDg;
596 char *lpVendorInfo;
597 char szDescription[WSADESCRIPTION_LEN+1];
598 char szSystemStatus[WSASYS_STATUS_LEN+1];
599 #else
600 char szDescription[WSADESCRIPTION_LEN+1];
601 char szSystemStatus[WSASYS_STATUS_LEN+1];
602 WORD iMaxSockets;
603 WORD iMaxUdpDg;
604 char *lpVendorInfo;
605 #endif
606 } WSADATA, *LPWSADATA;
611 * {get,set}sockopt
613 #ifndef USE_WS_PREFIX
614 #define SOL_SOCKET 0xffff
615 #define SO_DEBUG 0x0001
616 #define SO_ACCEPTCONN 0x0002
617 #define SO_REUSEADDR 0x0004
618 #define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
619 #define SO_KEEPALIVE 0x0008
620 #define SO_DONTROUTE 0x0010
621 #define SO_BROADCAST 0x0020
622 #define SO_USELOOPBACK 0x0040
623 #define SO_LINGER 0x0080
624 #define SO_OOBINLINE 0x0100
625 #define SO_DONTLINGER ((u_int)(~SO_LINGER))
626 #define SO_SNDBUF 0x1001
627 #define SO_RCVBUF 0x1002
628 #define SO_SNDLOWAT 0x1003
629 #define SO_RCVLOWAT 0x1004
630 #define SO_SNDTIMEO 0x1005
631 #define SO_RCVTIMEO 0x1006
632 #define SO_ERROR 0x1007
633 #define SO_TYPE 0x1008
635 #define IOCPARM_MASK 0x7f
636 #define IOC_VOID 0x20000000
637 #define IOC_OUT 0x40000000
638 #define IOC_IN 0x80000000
639 #define IOC_INOUT (IOC_IN|IOC_OUT)
641 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
642 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
643 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
645 #else
647 #define WS_SOL_SOCKET 0xffff
648 #define WS_SO_DEBUG 0x0001
649 #define WS_SO_ACCEPTCONN 0x0002
650 #define WS_SO_REUSEADDR 0x0004
651 #define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
652 #define WS_SO_KEEPALIVE 0x0008
653 #define WS_SO_DONTROUTE 0x0010
654 #define WS_SO_BROADCAST 0x0020
655 #define WS_SO_USELOOPBACK 0x0040
656 #define WS_SO_LINGER 0x0080
657 #define WS_SO_OOBINLINE 0x0100
658 #define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
659 #define WS_SO_SNDBUF 0x1001
660 #define WS_SO_RCVBUF 0x1002
661 #define WS_SO_SNDLOWAT 0x1003
662 #define WS_SO_RCVLOWAT 0x1004
663 #define WS_SO_SNDTIMEO 0x1005
664 #define WS_SO_RCVTIMEO 0x1006
665 #define WS_SO_ERROR 0x1007
666 #define WS_SO_TYPE 0x1008
668 #define WS_IOCPARM_MASK 0x7f
669 #define WS_IOC_VOID 0x20000000
670 #define WS_IOC_OUT 0x40000000
671 #define WS_IOC_IN 0x80000000
672 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
674 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
675 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
676 #define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
678 #endif
680 /* IPPROTO_TCP options */
681 #ifndef USE_WS_PREFIX
682 #define TCP_NODELAY 1
683 #else
684 #define WS_TCP_NODELAY 1
685 #endif
687 #ifndef USE_WS_PREFIX
688 # define IP_OPTIONS 1
689 # define IP_MULTICAST_IF 2
690 # define IP_MULTICAST_TTL 3
691 # define IP_MULTICAST_LOOP 4
692 # define IP_ADD_MEMBERSHIP 5
693 # define IP_DROP_MEMBERSHIP 6
694 # define IP_TTL 7
695 # define IP_TOS 8
696 # define IP_DONTFRAGMENT 9
697 #else
698 # define WS_IP_OPTIONS 1
699 # define WS_IP_MULTICAST_IF 2
700 # define WS_IP_MULTICAST_TTL 3
701 # define WS_IP_MULTICAST_LOOP 4
702 # define WS_IP_ADD_MEMBERSHIP 5
703 # define WS_IP_DROP_MEMBERSHIP 6
704 # define WS_IP_TTL 7
705 # define WS_IP_TOS 8
706 # define WS_IP_DONTFRAGMENT 9
707 #endif
711 * Socket I/O flags (supported by spec 1.1)
713 #ifndef USE_WS_PREFIX
714 #define FIONREAD _IOR('f', 127, ULONG)
715 #define FIONBIO _IOW('f', 126, ULONG)
716 #define FIOASYNC _IOW('f', 125, ULONG)
717 #define SIOCSHIWAT _IOW('s', 0, ULONG)
718 #define SIOCGHIWAT _IOR('s', 1, ULONG)
719 #define SIOCSLOWAT _IOW('s', 2, ULONG)
720 #define SIOCGLOWAT _IOR('s', 3, ULONG)
721 #define SIOCATMARK _IOR('s', 7, ULONG)
722 #else
723 #define WS_FIONREAD WS__IOR('f', 127, ULONG)
724 #define WS_FIONBIO WS__IOW('f', 126, ULONG)
725 #define WS_FIOASYNC WS__IOW('f', 125, ULONG)
726 #define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG)
727 #define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG)
728 #define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG)
729 #define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG)
730 #define WS_SIOCATMARK WS__IOR('s', 7, ULONG)
731 #endif
734 * Maximum queue length specifiable by listen.
736 #ifndef USE_WS_PREFIX
737 #define SOMAXCONN 5
739 #define MSG_OOB 0x0001
740 #define MSG_PEEK 0x0002
741 #define MSG_DONTROUTE 0x0004
742 #define MSG_PARTIAL 0x8000
743 #define MSG_MAXIOVLEN 16
744 #else /* USE_WS_PREFIX */
745 #define WS_SOMAXCONN 5
747 #define WS_MSG_OOB 0x0001
748 #define WS_MSG_PEEK 0x0002
749 #define WS_MSG_DONTROUTE 0x0004
750 #define WS_MSG_PARTIAL 0x8000
751 #define WS_MSG_MAXIOVLEN 16
752 #endif /* USE_WS_PREFIX */
755 * Define constant based on rfc883, used by gethostbyxxxx() calls.
757 #ifndef USE_WS_PREFIX
758 #define MAXGETHOSTSTRUCT 1024
759 #else
760 #define MAXGETHOSTSTRUCT 1024
761 #endif
765 * Define flags to be used with the WSAAsyncSelect() call.
767 #define FD_READ 0x00000001
768 #define FD_WRITE 0x00000002
769 #define FD_OOB 0x00000004
770 #define FD_ACCEPT 0x00000008
771 #define FD_CONNECT 0x00000010
772 #define FD_CLOSE 0x00000020
775 * All Windows Sockets error constants are biased by WSABASEERR from
776 * the "normal". They are also defined in winerror.h.
778 #define WSABASEERR 10000
780 * Windows Sockets definitions of regular Microsoft C error constants
782 #define WSAEINTR (WSABASEERR+4)
783 #define WSAEBADF (WSABASEERR+9)
784 #define WSAEACCES (WSABASEERR+13)
785 #define WSAEFAULT (WSABASEERR+14)
786 #define WSAEINVAL (WSABASEERR+22)
787 #define WSAEMFILE (WSABASEERR+24)
790 * Windows Sockets definitions of regular Berkeley error constants
792 #define WSAEWOULDBLOCK (WSABASEERR+35)
793 #define WSAEINPROGRESS (WSABASEERR+36)
794 #define WSAEALREADY (WSABASEERR+37)
795 #define WSAENOTSOCK (WSABASEERR+38)
796 #define WSAEDESTADDRREQ (WSABASEERR+39)
797 #define WSAEMSGSIZE (WSABASEERR+40)
798 #define WSAEPROTOTYPE (WSABASEERR+41)
799 #define WSAENOPROTOOPT (WSABASEERR+42)
800 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
801 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
802 #define WSAEOPNOTSUPP (WSABASEERR+45)
803 #define WSAEPFNOSUPPORT (WSABASEERR+46)
804 #define WSAEAFNOSUPPORT (WSABASEERR+47)
805 #define WSAEADDRINUSE (WSABASEERR+48)
806 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
807 #define WSAENETDOWN (WSABASEERR+50)
808 #define WSAENETUNREACH (WSABASEERR+51)
809 #define WSAENETRESET (WSABASEERR+52)
810 #define WSAECONNABORTED (WSABASEERR+53)
811 #define WSAECONNRESET (WSABASEERR+54)
812 #define WSAENOBUFS (WSABASEERR+55)
813 #define WSAEISCONN (WSABASEERR+56)
814 #define WSAENOTCONN (WSABASEERR+57)
815 #define WSAESHUTDOWN (WSABASEERR+58)
816 #define WSAETOOMANYREFS (WSABASEERR+59)
817 #define WSAETIMEDOUT (WSABASEERR+60)
818 #define WSAECONNREFUSED (WSABASEERR+61)
819 #define WSAELOOP (WSABASEERR+62)
820 #define WSAENAMETOOLONG (WSABASEERR+63)
821 #define WSAEHOSTDOWN (WSABASEERR+64)
822 #define WSAEHOSTUNREACH (WSABASEERR+65)
823 #define WSAENOTEMPTY (WSABASEERR+66)
824 #define WSAEPROCLIM (WSABASEERR+67)
825 #define WSAEUSERS (WSABASEERR+68)
826 #define WSAEDQUOT (WSABASEERR+69)
827 #define WSAESTALE (WSABASEERR+70)
828 #define WSAEREMOTE (WSABASEERR+71)
831 * Extended Windows Sockets error constant definitions
833 #define WSASYSNOTREADY (WSABASEERR+91)
834 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
835 #define WSANOTINITIALISED (WSABASEERR+93)
836 #define WSAEDISCON (WSABASEERR+101)
839 * Error return codes from gethostbyname() and gethostbyaddr()
840 * (when using the resolver). Note that these errors are
841 * retrieved via WSAGetLastError() and must therefore follow
842 * the rules for avoiding clashes with error numbers from
843 * specific implementations or language run-time systems.
844 * For this reason the codes are based at WSABASEERR+1001.
845 * Note also that [WSA]NO_ADDRESS is defined only for
846 * compatibility purposes.
849 #ifndef USE_WS_PREFIX
850 #define h_errno WSAGetLastError()
851 #else
852 #define WS_h_errno WSAGetLastError()
853 #endif
855 /* Authoritative Answer: Host not found */
856 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
858 /* Non-Authoritative: Host not found, or SERVERFAIL */
859 #define WSATRY_AGAIN (WSABASEERR+1002)
861 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
862 #define WSANO_RECOVERY (WSABASEERR+1003)
864 /* Valid name, no data record of requested type */
865 #define WSANO_DATA (WSABASEERR+1004)
867 /* no address, look for MX record */
868 #define WSANO_ADDRESS WSANO_DATA
870 #ifndef USE_WS_PREFIX
871 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
872 #define TRY_AGAIN WSATRY_AGAIN
873 #define NO_RECOVERY WSANO_RECOVERY
874 #define NO_DATA WSANO_DATA
875 #define NO_ADDRESS WSANO_ADDRESS
876 #endif /* USE_WS_PREFIX */
881 * Windows message parameter composition and decomposition
882 * macros.
886 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
887 * when constructing the response to a WSAAsyncGetXByY() routine.
889 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
891 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
892 * when constructing the response to WSAAsyncSelect().
894 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
896 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
897 * to extract the buffer length from the lParam in the response
898 * to a WSAGetXByY().
900 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
902 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
903 * to extract the error code from the lParam in the response
904 * to a WSAGetXByY().
906 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
908 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
909 * to extract the event code from the lParam in the response
910 * to a WSAAsyncSelect().
912 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
914 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
915 * to extract the error code from the lParam in the response
916 * to a WSAAsyncSelect().
918 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
923 * Prototypes
925 * Remember to keep this section in sync with the
926 * "Winsock Function Typedefs" section in winsock2.h.
928 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
929 HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
930 HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
931 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
932 HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
933 HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
934 int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
935 int WINAPI WSACancelAsyncRequest(HANDLE);
936 int WINAPI WSACancelBlockingCall(void);
937 int WINAPI WSACleanup(void);
938 int WINAPI WSAGetLastError(void);
939 BOOL WINAPI WSAIsBlocking(void);
940 FARPROC WINAPI WSASetBlockingHook(FARPROC);
941 void WINAPI WSASetLastError(int);
942 int WINAPI WSAStartup(WORD,LPWSADATA);
943 int WINAPI WSAUnhookBlockingHook(void);
945 SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
946 int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
947 int WINAPI WS(closesocket)(SOCKET);
948 int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
949 struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
950 struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
951 int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
952 struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
953 struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
954 #ifdef WS_DEFINE_SELECT
955 int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
956 #endif
957 struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
958 struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
959 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
960 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
961 ULONG WINAPI WS(inet_addr)(const char*);
962 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
963 int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
964 int WINAPI WS(listen)(SOCKET,int);
965 int WINAPI WS(recv)(SOCKET,char*,int,int);
966 int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
967 int WINAPI WS(send)(SOCKET,const char*,int,int);
968 int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
969 int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
970 int WINAPI WS(shutdown)(SOCKET,int);
971 SOCKET WINAPI WS(socket)(int,int,int);
973 #if defined(__MINGW32__) || defined (_MSC_VER) || defined(__WINE_USE_MSVCRT)
974 /* gethostname is not defined on Unix because of conflicts with unistd.h */
975 int WINAPI WS(gethostname)(char*,int);
976 #endif
978 #ifdef __cplusplus
980 #endif
982 #undef WS
984 #endif /* _WINSOCKAPI_ */