1 /***********************************************************************\
2 *                              winsock2.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                             by Daniel Keep                            *
8 \***********************************************************************/
9 module windows.winsock2;
10 pragma(lib, "Ws2_32");
11 nothrow:
12 /*
13   Definitions for winsock 2
14 
15   Contributed by the WINE project.
16 
17   Portions Copyright (c) 1980, 1983, 1988, 1993
18   The Regents of the University of California.  All rights reserved.
19 
20   Portions Copyright (c) 1993 by Digital Equipment Corporation.
21  */
22 
23 /*	DRK: This module should not be included if -version=Win32_Winsock2 has
24  *	not been set.  If it has, assert.  I think it's better this way than
25  *	letting the user believe that it's worked.
26  *
27  *	SG: It has now been changed so that winsock2 is the default, and
28  *	-version=Win32_Winsock1 must be set to use winsock.
29  */
30 version(Win32_Winsock1) {
31 	pragma(msg, "Cannot use windows.winsock2 with Win32_Winsock1 defined.");
32 	static assert(false);
33 }
34 
35 import windows.winbase;
36 import windows.windef;
37 import windows.basetyps;
38 
39 alias char u_char;
40 alias ushort u_short;
41 alias uint u_int, u_long;
42 alias size_t SOCKET;
43 
44 const size_t FD_SETSIZE = 64;
45 
46 /* shutdown() how types */
47 enum : int {
48 	SD_RECEIVE,
49 	SD_SEND,
50 	SD_BOTH
51 }
52 
53 /* Good grief this is stupid... is it a struct?  A preprocessor macro?  A
54    struct tag?  Who the hell knows!? */
55 struct FD_SET {
56 	u_int               fd_count;
57 	SOCKET[FD_SETSIZE]  fd_array;
58 
59 	/* this differs from the define in winsock.h and in cygwin sys/types.h */
60 	static void opCall(SOCKET fd, FD_SET set) {
61 		u_int i;
62 		for (i = 0; i < set.fd_count; i++)
63 			if (set.fd_array[i] == fd)
64 				break;
65 		if (i == set.fd_count)
66 			if (set.fd_count < FD_SETSIZE) {
67 				set.fd_array[i] = fd;
68 				set.fd_count++;
69 			}
70 	}
71 }
72 alias FD_SET* PFD_SET, LPFD_SET;
73 
74 // Keep this alias, since fd_set isn't a tag name in the original header.
75 alias FD_SET fd_set;
76 
77 extern(Windows) int __WSAFDIsSet(SOCKET, FD_SET*);
78 alias __WSAFDIsSet FD_ISSET;
79 
80 void FD_CLR(SOCKET fd, FD_SET* set) {
81 	for (u_int i = 0; i < set.fd_count; i++) {
82 		if (set.fd_array[i] == fd) {
83 			while (i < set.fd_count - 1) {
84 				set.fd_array[i] = set.fd_array[i+1];
85 				i++;
86 			}
87 			set.fd_count--;
88 			break;
89 		}
90 	}
91 }
92 
93 void FD_ZERO(FD_SET* set) {
94 	set.fd_count = 0;
95 }
96 
97 
98 struct TIMEVAL {
99 	int tv_sec;
100 	int tv_usec;
101 
102 	int opCmp(TIMEVAL tv) {
103 		if (tv_sec < tv.tv_sec)   return -1;
104 		if (tv_sec > tv.tv_sec)   return  1;
105 		if (tv_usec < tv.tv_usec) return -1;
106 		if (tv_usec > tv.tv_usec) return  1;
107 		return 0;
108 	}
109 }
110 alias TIMEVAL* PTIMEVAL, LPTIMEVAL;
111 
112 bool timerisset(TIMEVAL* tvp) {
113 	return tvp.tv_sec || tvp.tv_usec;
114 }
115 
116 /+
117 /* DRK: These have been commented out because it was felt that using
118  * omCmp on the TIMEVAL struct was cleaner.  Still, perhaps these should
119  * be enabled under a version tag for compatibility's sake?
120  * If it is decided that it's just ugly and unwanted, then feel free to
121  * delete this section :)
122  */
123 int timercmp(TIMEVAL* tvp, TIMEVAL* uvp) {
124 	return tvp.tv_sec != uvp.tv_sec ?
125 	    (tvp.tv_sec < uvp.tv_sec ? -1 :
126             (tvp.tv_sec > uvp.tv_sec ? 1 : 0)) :
127 	    (tvp.tv_usec < uvp.tv_usec ? -1 :
128 	        (tvp.tv_usec > uvp.tv_usec ? 1 : 0));
129 }
130 
131 int timercmp(TIMEVAL* tvp, TIMEVAL* uvp, int function(long,long) cmp) {
132 	return tvp.tv_sec != uvp.tv_sec ?
133 	    cmp(tvp.tv_sec, uvp.tv_sec) :
134 	    cmp(tvp.tv_usec, uvp.tv_usec);
135 }+/
136 
137 void timerclear(ref TIMEVAL tvp) {
138 	tvp.tv_sec = tvp.tv_usec = 0;
139 }
140 
141 struct HOSTENT {
142 	char*  h_name;
143 	char** h_aliases;
144 	short  h_addrtype;
145 	short  h_length;
146 	char** h_addr_list;
147 
148 	char* h_addr() { return h_addr_list[0]; }
149 	char* h_addr(char* h) { return h_addr_list[0] = h; }
150 }
151 alias HOSTENT* PHOSTENT, LPHOSTENT;
152 
153 struct LINGER {
154 	u_short l_onoff;
155 	u_short l_linger;
156 }
157 alias LINGER* PLINGER, LPLINGER;
158 
159 enum : DWORD {
160 	IOCPARAM_MASK = 0x7f,
161 	IOC_VOID      = 0x20000000,
162 	IOC_OUT       = 0x40000000,
163 	IOC_IN        = 0x80000000,
164 	IOC_INOUT     = IOC_IN|IOC_OUT
165 }
166 
167 // NOTE: This isn't even used anywhere...
168 template _IO(char x, ubyte y) {
169 	const DWORD _IO = IOC_VOID | (cast(ubyte)x<<8) | y;
170 }
171 
172 template _IOR(char x, ubyte y, t) {
173 	const DWORD _IOR = IOC_OUT | ((t.sizeof & IOCPARAM_MASK)<<16)
174 		| (cast(ubyte)x<<8) | y;
175 }
176 
177 template _IOW(char x, ubyte y, t) {
178 	const DWORD _IOW = IOC_IN | ((t.sizeof & IOCPARAM_MASK)<<16)
179 		| (cast(ubyte)x<<8) | y;
180 }
181 
182 enum : DWORD {
183 	FIONBIO    = _IOW!('f', 126, u_long),
184 	FIONREAD   = _IOR!('f', 127, u_long),
185 	FIOASYNC   = _IOW!('f', 125, u_long),
186 	SIOCSHIWAT = _IOW!('s',   0, u_long),
187 	SIOCGHIWAT = _IOR!('s',   1, u_long),
188 	SIOCSLOWAT = _IOW!('s',   2, u_long),
189 	SIOCGLOWAT = _IOR!('s',   3, u_long),
190 	SIOCATMARK = _IOR!('s',   7, u_long)
191 }
192 
193 struct netent {
194 	char*  n_name;
195 	char** n_aliases;
196 	short  n_addrtype;
197 	u_long n_net;
198 }
199 
200 struct SERVENT {
201 	char*  s_name;
202 	char** s_aliases;
203 	short  s_port;
204 	char*  s_proto;
205 }
206 alias SERVENT* PSERVENT, LPSERVENT;
207 
208 struct PROTOENT {
209 	char*  p_name;
210 	char** p_aliases;
211 	short  p_proto;
212 }
213 alias PROTOENT* PPROTOENT, LPPROTOENT;
214 
215 enum : int {
216 	IPPROTO_IP   =   0,
217 	IPPROTO_ICMP =   1,
218 	IPPROTO_IGMP =   2,
219 	IPPROTO_GGP  =   3,
220 	IPPROTO_TCP  =   6,
221 	IPPROTO_PUP  =  12,
222 	IPPROTO_UDP  =  17,
223 	IPPROTO_IDP  =  22,
224 	IPPROTO_ND   =  77,
225 	IPPROTO_RAW  = 255,
226 	IPPROTO_MAX  = 256,
227 
228 	// IPv6 options
229 	IPPROTO_HOPOPTS  =  0, // IPv6 Hop-by-Hop options
230 	IPPROTO_IPV6     = 41, // IPv6 header
231 	IPPROTO_ROUTING  = 43, // IPv6 Routing header
232 	IPPROTO_FRAGMENT = 44, // IPv6 fragmentation header
233 	IPPROTO_ESP      = 50, // encapsulating security payload
234 	IPPROTO_AH       = 51, // authentication header
235 	IPPROTO_ICMPV6   = 58, // ICMPv6
236 	IPPROTO_NONE     = 59, // IPv6 no next header
237 	IPPROTO_DSTOPTS  = 60  // IPv6 Destination options
238 }
239 
240 enum {
241 	IPPORT_ECHO        =    7,
242 	IPPORT_DISCARD     =    9,
243 	IPPORT_SYSTAT      =   11,
244 	IPPORT_DAYTIME     =   13,
245 	IPPORT_NETSTAT     =   15,
246 	IPPORT_FTP         =   21,
247 	IPPORT_TELNET      =   23,
248 	IPPORT_SMTP        =   25,
249 	IPPORT_TIMESERVER  =   37,
250 	IPPORT_NAMESERVER  =   42,
251 	IPPORT_WHOIS       =   43,
252 	IPPORT_MTP         =   57,
253 	IPPORT_TFTP        =   69,
254 	IPPORT_RJE         =   77,
255 	IPPORT_FINGER      =   79,
256 	IPPORT_TTYLINK     =   87,
257 	IPPORT_SUPDUP      =   95,
258 	IPPORT_EXECSERVER  =  512,
259 	IPPORT_LOGINSERVER =  513,
260 	IPPORT_CMDSERVER   =  514,
261 	IPPORT_EFSSERVER   =  520,
262 	IPPORT_BIFFUDP     =  512,
263 	IPPORT_WHOSERVER   =  513,
264 	IPPORT_ROUTESERVER =  520,
265 	IPPORT_RESERVED    = 1024
266 }
267 
268 enum {
269 	IMPLINK_IP         =  155,
270 	IMPLINK_LOWEXPER   =  156,
271 	IMPLINK_HIGHEXPER  =  158
272 }
273 
274 struct IN_ADDR {
275 	union {
276 		struct { u_char  s_b1, s_b2, s_b3, s_b4; }
277 		struct { u_char  s_net, s_host, s_lh, s_impno; }
278 		struct { u_short s_w1, s_w2; }
279 		struct { u_short s_w_, s_imp; } // Can I get rid of s_w_ using alignment tricks?
280 		u_long S_addr;
281 		u_long s_addr;
282 	}
283 }
284 alias IN_ADDR* PIN_ADDR, LPIN_ADDR;
285 
286 // IN_CLASSx are not used anywhere or documented on MSDN.
287 bool IN_CLASSA(int i) { return (i & 0x80000000) == 0; }
288 
289 const IN_CLASSA_NET    = 0xff000000;
290 const IN_CLASSA_NSHIFT =         24;
291 const IN_CLASSA_HOST   = 0x00ffffff;
292 const IN_CLASSA_MAX    =        128;
293 
294 bool IN_CLASSB(int i) { return (i & 0xc0000000) == 0x80000000; }
295 
296 const IN_CLASSB_NET    = 0xffff0000;
297 const IN_CLASSB_NSHIFT =         16;
298 const IN_CLASSB_HOST   = 0x0000ffff;
299 const IN_CLASSB_MAX    =      65536;
300 
301 bool IN_CLASSC(int i) { return (i & 0xe0000000) == 0xc0000000; }
302 
303 const IN_CLASSC_NET    = 0xffffff00;
304 const IN_CLASSC_NSHIFT =          8;
305 const IN_CLASSC_HOST   = 0x000000ff;
306 
307 const u_long
308 	INADDR_ANY       = 0,
309 	INADDR_LOOPBACK  = 0x7F000001,
310 	INADDR_BROADCAST = 0xFFFFFFFF,
311 	INADDR_NONE      = 0xFFFFFFFF;
312 
313 struct SOCKADDR_IN {
314 	short   sin_family;
315 	u_short sin_port;
316 	IN_ADDR sin_addr;
317 	char[8] sin_zero;
318 }
319 alias SOCKADDR_IN* PSOCKADDR_IN, LPSOCKADDR_IN;
320 
321 const size_t
322 	WSADESCRIPTION_LEN = 256,
323 	WSASYS_STATUS_LEN  = 128;
324 
325 struct WSADATA {
326 	WORD   wVersion;
327 	WORD   wHighVersion;
328 	char[WSADESCRIPTION_LEN+1] szDescription;
329 	char[WSASYS_STATUS_LEN+1]  szSystemStatus;
330 	ushort iMaxSockets;
331 	ushort iMaxUdpDg;
332 	char*  lpVendorInfo;
333 }
334 alias WSADATA* LPWSADATA;
335 
336 // This is not documented on the MSDN site
337 const IP_OPTIONS = 1;
338 
339 const int
340 	SO_OPTIONS     =   1,
341 	SO_DEBUG       =   1,
342 	SO_ACCEPTCONN  =   2,
343 	SO_REUSEADDR   =   4,
344 	SO_KEEPALIVE   =   8,
345 	SO_DONTROUTE   =  16,
346 	SO_BROADCAST   =  32,
347 	SO_USELOOPBACK =  64,
348 	SO_LINGER      = 128,
349 	SO_OOBINLINE   = 256,
350 	SO_DONTLINGER  = ~SO_LINGER,
351 	SO_EXCLUSIVEADDRUSE= ~SO_REUSEADDR;
352 
353 enum : int {
354 	SO_SNDBUF = 0x1001,
355 	SO_RCVBUF,
356 	SO_SNDLOWAT,
357 	SO_RCVLOWAT,
358 	SO_SNDTIMEO,
359 	SO_RCVTIMEO,
360 	SO_ERROR,
361 	SO_TYPE // = 0x1008
362 }
363 
364 const SOCKET INVALID_SOCKET = cast(SOCKET)(~0);
365 const int SOCKET_ERROR = -1;
366 
367 enum : int {
368 	SOCK_STREAM = 1,
369 	SOCK_DGRAM,
370 	SOCK_RAW,
371 	SOCK_RDM,
372 	SOCK_SEQPACKET
373 }
374 
375 const int TCP_NODELAY = 0x0001;
376 
377 enum : int {
378 	AF_UNSPEC,
379 	AF_UNIX,
380 	AF_INET,
381 	AF_IMPLINK,
382 	AF_PUP,
383 	AF_CHAOS,
384 	AF_IPX,  // =  6
385 	AF_NS       =  6,
386 	AF_ISO,
387 	AF_OSI      = AF_ISO,
388 	AF_ECMA,
389 	AF_DATAKIT,
390 	AF_CCITT,
391 	AF_SNA,
392 	AF_DECnet,
393 	AF_DLI,
394 	AF_LAT,
395 	AF_HYLINK,
396 	AF_APPLETALK,
397 	AF_NETBIOS,
398 	AF_VOICEVIEW,
399 	AF_FIREFOX,
400 	AF_UNKNOWN1,
401 	AF_BAN,
402 	AF_ATM,
403 	AF_INET6,
404 	// AF_CLUSTER, AF_12844 nad AF_NETDES are not documented on MSDN
405 	AF_CLUSTER,
406 	AF_12844,
407 	AF_IRDA, // = 26
408 	AF_NETDES   = 28,
409 	AF_MAX   // = 29
410 }
411 
412 struct SOCKADDR {
413 	u_short  sa_family;
414 	char[14] sa_data;
415 }
416 alias SOCKADDR* PSOCKADDR, LPSOCKADDR;
417 
418 /* Portable IPv6/IPv4 version of sockaddr.
419    Uses padding to force 8 byte alignment
420    and maximum size of 128 bytes */
421 struct SOCKADDR_STORAGE {
422     short     ss_family;
423     char[6]   __ss_pad1;   // pad to 8
424     long      __ss_align;  // force alignment
425     char[112] __ss_pad2;   // pad to 128
426 }
427 alias SOCKADDR_STORAGE* PSOCKADDR_STORAGE;
428 
429 struct sockproto {
430 	u_short sp_family;
431 	u_short sp_protocol;
432 }
433 
434 enum : int {
435 	PF_UNSPEC    = AF_UNSPEC,
436 	PF_UNIX      = AF_UNIX,
437 	PF_INET      = AF_INET,
438 	PF_IMPLINK   = AF_IMPLINK,
439 	PF_PUP       = AF_PUP,
440 	PF_CHAOS     = AF_CHAOS,
441 	PF_NS        = AF_NS,
442 	PF_IPX       = AF_IPX,
443 	PF_ISO       = AF_ISO,
444 	PF_OSI       = AF_OSI,
445 	PF_ECMA      = AF_ECMA,
446 	PF_DATAKIT   = AF_DATAKIT,
447 	PF_CCITT     = AF_CCITT,
448 	PF_SNA       = AF_SNA,
449 	PF_DECnet    = AF_DECnet,
450 	PF_DLI       = AF_DLI,
451 	PF_LAT       = AF_LAT,
452 	PF_HYLINK    = AF_HYLINK,
453 	PF_APPLETALK = AF_APPLETALK,
454 	PF_VOICEVIEW = AF_VOICEVIEW,
455 	PF_FIREFOX   = AF_FIREFOX,
456 	PF_UNKNOWN1  = AF_UNKNOWN1,
457 	PF_BAN       = AF_BAN,
458 	PF_ATM       = AF_ATM,
459 	PF_INET6     = AF_INET6,
460 	PF_MAX       = AF_MAX
461 }
462 
463 const int SOL_SOCKET = 0xFFFF;
464 
465 const int SOMAXCONN = 5;
466 
467 const int
468 	MSG_OOB       = 1,
469 	MSG_PEEK      = 2,
470 	MSG_DONTROUTE = 4,
471 	MSG_MAXIOVLEN = 16,
472 	MSG_PARTIAL   = 0x8000;
473 
474 const size_t MAXGETHOSTSTRUCT = 1024;
475 
476 // Not documented on MSDN
477 enum {
478 	FD_READ_BIT,
479 	FD_WRITE_BIT,
480 	FD_OOB_BIT,
481 	FD_ACCEPT_BIT,
482 	FD_CONNECT_BIT,
483 	FD_CLOSE_BIT,
484 	FD_QOS_BIT,
485 	FD_GROUP_QOS_BIT,
486 	FD_ROUTING_INTERFACE_CHANGE_BIT,
487 	FD_ADDRESS_LIST_CHANGE_BIT,
488 	FD_MAX_EVENTS // = 10
489 }
490 
491 const int
492 	FD_READ                     = 1 << FD_READ_BIT,
493 	FD_WRITE                    = 1 << FD_WRITE_BIT,
494 	FD_OOB                      = 1 << FD_OOB_BIT,
495 	FD_ACCEPT                   = 1 << FD_ACCEPT_BIT,
496 	FD_CONNECT                  = 1 << FD_CONNECT_BIT,
497 	FD_CLOSE                    = 1 << FD_CLOSE_BIT,
498 	FD_QOS                      = 1 << FD_QOS_BIT,
499 	FD_GROUP_QOS                = 1 << FD_GROUP_QOS_BIT,
500 	FD_ROUTING_INTERFACE_CHANGE = 1 << FD_ROUTING_INTERFACE_CHANGE_BIT,
501 	FD_ADDRESS_LIST_CHANGE      = 1 << FD_ADDRESS_LIST_CHANGE_BIT,
502 	FD_ALL_EVENTS               = (1 << FD_MAX_EVENTS) - 1;
503 
504 enum : int {
505 	WSABASEERR         = 10000,
506 	WSAEINTR           = WSABASEERR + 4,
507 	WSAEBADF           = WSABASEERR + 9,
508 	WSAEACCES          = WSABASEERR + 13,
509 	WSAEFAULT          = WSABASEERR + 14,
510 	WSAEINVAL          = WSABASEERR + 22,
511 	WSAEMFILE          = WSABASEERR + 24,
512 	WSAEWOULDBLOCK     = WSABASEERR + 35,
513 	WSAEINPROGRESS     = WSABASEERR + 36, // deprecated on WinSock2
514 	WSAEALREADY        = WSABASEERR + 37,
515 	WSAENOTSOCK        = WSABASEERR + 38,
516 	WSAEDESTADDRREQ    = WSABASEERR + 39,
517 	WSAEMSGSIZE        = WSABASEERR + 40,
518 	WSAEPROTOTYPE      = WSABASEERR + 41,
519 	WSAENOPROTOOPT     = WSABASEERR + 42,
520 	WSAEPROTONOSUPPORT = WSABASEERR + 43,
521 	WSAESOCKTNOSUPPORT = WSABASEERR + 44,
522 	WSAEOPNOTSUPP      = WSABASEERR + 45,
523 	WSAEPFNOSUPPORT    = WSABASEERR + 46,
524 	WSAEAFNOSUPPORT    = WSABASEERR + 47,
525 	WSAEADDRINUSE      = WSABASEERR + 48,
526 	WSAEADDRNOTAVAIL   = WSABASEERR + 49,
527 	WSAENETDOWN        = WSABASEERR + 50,
528 	WSAENETUNREACH     = WSABASEERR + 51,
529 	WSAENETRESET       = WSABASEERR + 52,
530 	WSAECONNABORTED    = WSABASEERR + 53,
531 	WSAECONNRESET      = WSABASEERR + 54,
532 	WSAENOBUFS         = WSABASEERR + 55,
533 	WSAEISCONN         = WSABASEERR + 56,
534 	WSAENOTCONN        = WSABASEERR + 57,
535 	WSAESHUTDOWN       = WSABASEERR + 58,
536 	WSAETOOMANYREFS    = WSABASEERR + 59,
537 	WSAETIMEDOUT       = WSABASEERR + 60,
538 	WSAECONNREFUSED    = WSABASEERR + 61,
539 	WSAELOOP           = WSABASEERR + 62,
540 	WSAENAMETOOLONG    = WSABASEERR + 63,
541 	WSAEHOSTDOWN       = WSABASEERR + 64,
542 	WSAEHOSTUNREACH    = WSABASEERR + 65,
543 	WSAENOTEMPTY       = WSABASEERR + 66,
544 	WSAEPROCLIM        = WSABASEERR + 67,
545 	WSAEUSERS          = WSABASEERR + 68,
546 	WSAEDQUOT          = WSABASEERR + 69,
547 	WSAESTALE          = WSABASEERR + 70,
548 	WSAEREMOTE         = WSABASEERR + 71,
549 	WSAEDISCON         = WSABASEERR + 101,
550 	WSASYSNOTREADY     = WSABASEERR + 91,
551 	WSAVERNOTSUPPORTED = WSABASEERR + 92,
552 	WSANOTINITIALISED  = WSABASEERR + 93,
553 	WSAHOST_NOT_FOUND  = WSABASEERR + 1001,
554 	WSATRY_AGAIN       = WSABASEERR + 1002,
555 	WSANO_RECOVERY     = WSABASEERR + 1003,
556 	WSANO_DATA         = WSABASEERR + 1004,
557 	WSANO_ADDRESS      = WSANO_DATA,
558 
559 	// WinSock2 specific error codes
560 	WSAENOMORE             = WSABASEERR + 102,
561 	WSAECANCELLED          = WSABASEERR + 103,
562 	WSAEINVALIDPROCTABLE   = WSABASEERR + 104,
563 	WSAEINVALIDPROVIDER    = WSABASEERR + 105,
564 	WSAEPROVIDERFAILEDINIT = WSABASEERR + 106,
565 	WSASYSCALLFAILURE      = WSABASEERR + 107,
566 	WSASERVICE_NOT_FOUND   = WSABASEERR + 108,
567 	WSATYPE_NOT_FOUND      = WSABASEERR + 109,
568 	WSA_E_NO_MORE          = WSABASEERR + 110,
569 	WSA_E_CANCELLED        = WSABASEERR + 111,
570 	WSAEREFUSED            = WSABASEERR + 112,
571 
572 	// WS QualityofService errors
573 	WSA_QOS_RECEIVERS          = WSABASEERR + 1005,
574 	WSA_QOS_SENDERS            = WSABASEERR + 1006,
575 	WSA_QOS_NO_SENDERS         = WSABASEERR + 1007,
576 	WSA_QOS_NO_RECEIVERS       = WSABASEERR + 1008,
577 	WSA_QOS_REQUEST_CONFIRMED  = WSABASEERR + 1009,
578 	WSA_QOS_ADMISSION_FAILURE  = WSABASEERR + 1010,
579 	WSA_QOS_POLICY_FAILURE     = WSABASEERR + 1011,
580 	WSA_QOS_BAD_STYLE          = WSABASEERR + 1012,
581 	WSA_QOS_BAD_OBJECT         = WSABASEERR + 1013,
582 	WSA_QOS_TRAFFIC_CTRL_ERROR = WSABASEERR + 1014,
583 	WSA_QOS_GENERIC_ERROR      = WSABASEERR + 1015,
584 	WSA_QOS_ESERVICETYPE       = WSABASEERR + 1016,
585 	WSA_QOS_EFLOWSPEC          = WSABASEERR + 1017,
586 	WSA_QOS_EPROVSPECBUF       = WSABASEERR + 1018,
587 	WSA_QOS_EFILTERSTYLE       = WSABASEERR + 1019,
588 	WSA_QOS_EFILTERTYPE        = WSABASEERR + 1020,
589 	WSA_QOS_EFILTERCOUNT       = WSABASEERR + 1021,
590 	WSA_QOS_EOBJLENGTH         = WSABASEERR + 1022,
591 	WSA_QOS_EFLOWCOUNT         = WSABASEERR + 1023,
592 	WSA_QOS_EUNKOWNPSOBJ       = WSABASEERR + 1024,
593 	WSA_QOS_EPOLICYOBJ         = WSABASEERR + 1025,
594 	WSA_QOS_EFLOWDESC          = WSABASEERR + 1026,
595 	WSA_QOS_EPSFLOWSPEC        = WSABASEERR + 1027,
596 	WSA_QOS_EPSFILTERSPEC      = WSABASEERR + 1028,
597 	WSA_QOS_ESDMODEOBJ         = WSABASEERR + 1029,
598 	WSA_QOS_ESHAPERATEOBJ      = WSABASEERR + 1030,
599 	WSA_QOS_RESERVED_PETYPE    = WSABASEERR + 1031
600 }
601 
602 alias WSAGetLastError h_errno;
603 
604 enum : int {
605 	HOST_NOT_FOUND = WSAHOST_NOT_FOUND,
606 	TRY_AGAIN      = WSATRY_AGAIN,
607 	NO_RECOVERY    = WSANO_RECOVERY,
608 	NO_DATA        = WSANO_DATA,
609 	NO_ADDRESS     = WSANO_ADDRESS
610 }
611 
612 extern (Windows) {
613 	SOCKET accept(SOCKET, SOCKADDR*, int*);
614 	int bind(SOCKET, const(SOCKADDR)*, int);
615 	int closesocket(SOCKET);
616 	int connect(SOCKET, const(SOCKADDR)*, int);
617 	int ioctlsocket(SOCKET, int, u_long*);
618 	int getpeername(SOCKET, SOCKADDR*, int*);
619 	int getsockname(SOCKET, SOCKADDR*, int*);
620 	int getsockopt(SOCKET, int, int, void*, int*);
621 	uint inet_addr(const(char)*);
622 	int listen(SOCKET, int);
623 	int recv(SOCKET, ubyte*, int, int);
624 	int recvfrom(SOCKET, ubyte*, int, int, SOCKADDR*, int*);
625 	int send(SOCKET, const(ubyte)*, int, int);
626 	int sendto(SOCKET, const(ubyte)*, int, int, const(SOCKADDR)*, int);
627 	int setsockopt(SOCKET, int, int, const(void)*, int);
628 	int shutdown(SOCKET, int);
629 	SOCKET socket(int, int, int);
630 
631 	alias typeof(&accept) LPFN_ACCEPT;
632 	alias typeof(&bind) LPFN_BIND;
633 	alias typeof(&closesocket) LPFN_CLOSESOCKET;
634 	alias typeof(&connect) LPFN_CONNECT;
635 	alias typeof(&ioctlsocket) LPFN_IOCTLSOCKET;
636 	alias typeof(&getpeername) LPFN_GETPEERNAME;
637 	alias typeof(&getsockname) LPFN_GETSOCKNAME;
638 	alias typeof(&getsockopt) LPFN_GETSOCKOPT;
639 	alias typeof(&inet_addr) LPFN_INET_ADDR;
640 	alias typeof(&listen) LPFN_LISTEN;
641 	alias typeof(&recv) LPFN_RECV;
642 	alias typeof(&recvfrom) LPFN_RECVFROM;
643 	alias typeof(&send) LPFN_SEND;
644 	alias typeof(&sendto) LPFN_SENDTO;
645 	alias typeof(&setsockopt) LPFN_SETSOCKOPT;
646 	alias typeof(&shutdown) LPFN_SHUTDOWN;
647 	alias typeof(&socket) LPFN_SOCKET;
648 }
649 
650 extern(Windows) {
651 	char* inet_ntoa(IN_ADDR);
652 	HOSTENT* gethostbyaddr(const(char)*, int, int);
653 	HOSTENT* gethostbyname(const(char)*);
654 	SERVENT* getservbyport(int, const(char)*);
655 	SERVENT* getservbyname(const(char)*, const(char)*);
656 	PROTOENT* getprotobynumber(int);
657 	PROTOENT* getprotobyname(const(char)*);
658 
659 	/* NOTE: DK: in the original headers, these were declared with
660 	   PASCAL linkage.  Since this is at odds with the definition
661 	   of the functions themselves, and also since MinGW seems to
662 	   treat the two interchangably, I have moved them here. */
663 	alias typeof(&inet_ntoa) LPFN_INET_NTOA;
664 	alias typeof(&gethostbyaddr) LPFN_GETHOSTBYADDR;
665 	alias typeof(&gethostbyname) LPFN_GETHOSTBYNAME;
666 	alias typeof(&getservbyport) LPFN_GETSERVBYPORT;
667 	alias typeof(&getservbyname) LPFN_GETSERVBYNAME;
668 	alias typeof(&getprotobynumber) LPFN_GETPROTOBYNUMBER;
669 	alias typeof(&getprotobyname) LPFN_GETPROTOBYNAME;
670 }
671 
672 extern(Windows) {
673 	int WSAStartup(WORD, LPWSADATA);
674 	int WSACleanup();
675 	void WSASetLastError(int);
676 	int WSAGetLastError();
677 
678 	alias typeof(&WSAStartup) LPFN_WSASTARTUP;
679 	alias typeof(&WSACleanup) LPFN_WSACLEANUP;
680 	alias typeof(&WSASetLastError) LPFN_WSASETLASTERROR;
681 	alias typeof(&WSAGetLastError) LPFN_WSAGETLASTERROR;
682 }
683 
684 /*
685  * Pseudo-blocking functions are deprecated in WinSock2
686  * spec. Use threads instead.
687  */
688 deprecated extern(Windows) {
689 	BOOL WSAIsBlocking();
690 	int WSAUnhookBlockingHook();
691 	FARPROC WSASetBlockingHook(FARPROC);
692 	int WSACancelBlockingCall();
693 
694 	alias typeof(&WSAIsBlocking) LPFN_WSAISBLOCKING;
695 	alias typeof(&WSAUnhookBlockingHook) LPFN_WSAUNHOOKBLOCKINGHOOK;
696 	alias typeof(&WSASetBlockingHook) LPFN_WSASETBLOCKINGHOOK;
697 	alias typeof(&WSACancelBlockingCall) LPFN_WSACANCELBLOCKINGCALL;
698 }
699 
700 extern(Windows) {
701 	HANDLE WSAAsyncGetServByName(HWND, u_int, const(char)*, const(char)*, char*, int);
702 	HANDLE WSAAsyncGetServByPort(HWND, u_int, int, const(char)*, char*, int);
703 	HANDLE WSAAsyncGetProtoByName(HWND, u_int, const(char)*, char*, int);
704 	HANDLE WSAAsyncGetProtoByNumber(HWND, u_int, int, char*, int);
705 	HANDLE WSAAsyncGetHostByName(HWND, u_int, const(char)*, char*, int);
706 	HANDLE WSAAsyncGetHostByAddr(HWND, u_int, const(char)*, int, int, char*, int);
707 	int WSACancelAsyncRequest(HANDLE);
708 	int WSAAsyncSelect(SOCKET, HWND, u_int, long);
709 
710 	alias typeof(&WSAAsyncGetServByName) LPFN_WSAAsyncGetServByName;
711 	alias typeof(&WSAAsyncGetServByPort) LPFN_WSAASYNCGETSERVBYPORT;
712 	alias typeof(&WSAAsyncGetProtoByName) LPFN_WSAASYNCGETPROTOBYNAME;
713 	alias typeof(&WSAAsyncGetProtoByNumber) LPFN_WSAASYNCGETPROTOBYNUMBER;
714 	alias typeof(&WSAAsyncGetHostByName) LPFN_WSAASYNCGETHOSTBYNAME;
715 	alias typeof(&WSAAsyncGetHostByAddr) LPFN_WSAASYNCGETHOSTBYADDR;
716 	alias typeof(&WSACancelAsyncRequest) LPFN_WSACANCELASYNCREQUEST;
717 	alias typeof(&WSAAsyncSelect) LPFN_WSAASYNCSELECT;
718 }
719 
720 extern(Windows) {
721 	u_long htonl(u_long);
722 	u_long ntohl(u_long);
723 	u_short htons(u_short);
724 	u_short ntohs(u_short);
725 	int select(int nfds, fd_set*, fd_set*, fd_set*, const(TIMEVAL)*);
726 
727 	alias typeof(&htonl) LPFN_HTONL;
728 	alias typeof(&ntohl) LPFN_NTOHL;
729 	alias typeof(&htons) LPFN_HTONS;
730 	alias typeof(&ntohs) LPFN_NTOHS;
731 	alias typeof(&select) LPFN_SELECT;
732 
733 	int gethostname(char*, int);
734 	alias typeof(&gethostname) LPFN_GETHOSTNAME;
735 }
736 
737 alias MAKELONG WSAMAKEASYNCREPLY, WSAMAKESELECTREPLY;
738 alias LOWORD WSAGETASYNCBUFLEN, WSAGETSELECTEVENT;
739 alias HIWORD WSAGETASYNCERROR, WSAGETSELECTERROR;
740 
741 
742 alias INADDR_ANY ADDR_ANY;
743 
744 bool IN_CLASSD(int i) { return (i & 0xf0000000) == 0xe0000000; }
745 
746 const IN_CLASSD_NET    = 0xf0000000;
747 const IN_CLASSD_NSHIFT =         28;
748 const IN_CLASSD_HOST   = 0x0fffffff;
749 
750 alias IN_CLASSD IN_MULTICAST;
751 
752 const FROM_PROTOCOL_INFO = -1;
753 
754 enum : int {
755 	SO_GROUP_ID = 0x2001,
756 	SO_GROUP_PRIORITY,
757 	SO_MAX_MSG_SIZE,
758 	SO_PROTOCOL_INFOA,
759 	SO_PROTOCOL_INFOW
760 }
761 // NOTE: These are logically part of the previous enum, but you can't
762 // have version statements in an enum body...
763 version(Unicode)
764 	const int SO_PROTOCOL_INFO = SO_PROTOCOL_INFOW;
765 else
766 	const int SO_PROTOCOL_INFO = SO_PROTOCOL_INFOA;
767 
768 const PVD_CONFIG = 0x3001;
769 
770 const MSG_INTERRUPT = 0x10;
771 //const MSG_MAXIOVLEN = 16; // Already declared above
772 
773 mixin DECLARE_HANDLE!("WSAEVENT");
774 alias WSAEVENT* LPWSAEVENT;
775 alias OVERLAPPED WSAOVERLAPPED;
776 alias OVERLAPPED* LPWSAOVERLAPPED;
777 
778 private import windows.winerror;
779 private import windows.winbase;
780 
781 enum {
782 	WSA_IO_PENDING        = ERROR_IO_PENDING,
783 	WSA_IO_INCOMPLETE     = ERROR_IO_INCOMPLETE,
784 	WSA_INVALID_HANDLE    = ERROR_INVALID_HANDLE,
785 	WSA_INVALID_PARAMETER = ERROR_INVALID_PARAMETER,
786 	WSA_NOT_ENOUGH_MEMORY = ERROR_NOT_ENOUGH_MEMORY,
787 	WSA_OPERATION_ABORTED = ERROR_OPERATION_ABORTED
788 }
789 
790 const WSA_INVALID_EVENT = cast(WSAEVENT)HANDLE.init;
791 const WSA_MAXIMUM_WAIT_EVENTS = MAXIMUM_WAIT_OBJECTS;
792 const WSA_WAIT_FAILED = cast(DWORD)-1;
793 const WSA_WAIT_EVENT_0 = WAIT_OBJECT_0;
794 const WSA_WAIT_IO_COMPLETION = WAIT_IO_COMPLETION;
795 const WSA_WAIT_TIMEOUT = WAIT_TIMEOUT;
796 const WSA_INFINITE = INFINITE;
797 
798 struct WSABUF {
799 	uint  len;
800 	char* buf;
801 }
802 
803 alias WSABUF* LPWSABUF;
804 
805 enum GUARANTEE {
806 	BestEffortService,
807 	ControlledLoadService,
808 	PredictiveService,
809 	GuaranteedDelayService,
810 	GuaranteedService
811 }
812 
813 /* TODO: FLOWSPEC and related definitions belong in qos.h */
814 
815 /*
816    Windows Sockets 2 Application Programming Interface,
817    revision 2.2.2 (1997) uses the type uint32 for SERVICETYPE
818    and the elements of _flowspec, but the type uint32 is not defined
819    or used anywhere else in the w32api. For now, just use
820    unsigned int, which is 32 bits on _WIN32 and _WIN64.
821 */
822 
823 alias uint SERVICETYPE;
824 
825 struct FLOWSPEC {
826 	uint        TokenRate;
827 	uint        TokenBucketSize;
828 	uint        PeakBandwidth;
829 	uint        Latency;
830 	uint        DelayVariation;
831 	SERVICETYPE ServiceType;
832 	uint        MaxSduSize;
833 	uint        MinimumPolicedSize;
834 }
835 
836 alias FLOWSPEC* PFLOWSPEC, LPFLOWSPEC;
837 
838 struct QOS
839 {
840 	FLOWSPEC SendingFlowspec;
841 	FLOWSPEC ReceivingFlowspec;
842 	WSABUF   ProviderSpecific;
843 }
844 
845 alias QOS* LPQOS;
846 
847 enum {
848 	CF_ACCEPT,
849 	CF_REJECT,
850 	CF_DEFER
851 }
852 
853 // REM: Already defined above
854 /*enum {
855 	SD_RECEIVE,
856 	SD_SEND,
857 	SD_BOTH
858 }*/
859 
860 alias uint GROUP;
861 
862 enum {
863 	SG_UNCONSTRAINED_GROUP = 0x01,
864 	SG_CONSTRAINED_GROUP
865 }
866 
867 struct WSANETWORKEVENTS {
868 	int lNetworkEvents;
869 	int[FD_MAX_EVENTS] iErrorCode;
870 }
871 
872 alias WSANETWORKEVENTS* LPWSANETWORKEVENTS;
873 
874 const MAX_PROTOCOL_CHAIN = 7;
875 
876 const BASE_PROTOCOL    = 1;
877 const LAYERED_PROTOCOL = 0;
878 
879 enum WSAESETSERVICEOP
880 {
881 	RNRSERVICE_REGISTER = 0,
882 	RNRSERVICE_DEREGISTER,
883 	RNRSERVICE_DELETE
884 }
885 
886 alias WSAESETSERVICEOP* PWSAESETSERVICEOP, LPWSAESETSERVICEOP;
887 
888 struct AFPROTOCOLS {
889 	INT iAddressFamily;
890 	INT iProtocol;
891 }
892 
893 alias AFPROTOCOLS* PAFPROTOCOLS, LPAFPROTOCOLS;
894 
895 enum WSAECOMPARATOR
896 {
897 	COMP_EQUAL = 0,
898 	COMP_NOTLESS
899 }
900 
901 alias WSAECOMPARATOR* PWSAECOMPARATOR, LPWSAECOMPARATOR;
902 
903 struct WSAVERSION
904 {
905 	DWORD          dwVersion;
906 	WSAECOMPARATOR ecHow;
907 }
908 
909 alias WSAVERSION* PWSAVERSION, LPWSAVERSION;
910 
911 // Import for SOCKET_ADDRESS, CSADDR_INFO
912 // import windows.nspapi;
913 //#ifndef __CSADDR_T_DEFINED /* also in nspapi.h */
914 //#define __CSADDR_T_DEFINED
915 
916 struct SOCKET_ADDRESS {
917 	LPSOCKADDR lpSockaddr;
918 	INT        iSockaddrLength;
919 }
920 
921 alias SOCKET_ADDRESS* PSOCKET_ADDRESS, LPSOCKET_ADDRESS;
922 
923 struct CSADDR_INFO {
924 	SOCKET_ADDRESS LocalAddr;
925 	SOCKET_ADDRESS RemoteAddr;
926 	INT            iSocketType;
927 	INT            iProtocol;
928 }
929 
930 alias CSADDR_INFO* PCSADDR_INFO, LPCSADDR_INFO;
931 
932 //#endif
933 
934 struct SOCKET_ADDRESS_LIST {
935     INT               iAddressCount;
936     SOCKET_ADDRESS[1] _Address;
937     SOCKET_ADDRESS* Address() return { return _Address.ptr; }
938 }
939 
940 alias SOCKET_ADDRESS_LIST* LPSOCKET_ADDRESS_LIST;
941 
942 // TODO: Import wtypes/nspapi?
943 //#ifndef __BLOB_T_DEFINED /* also in wtypes.h and nspapi.h */
944 //#define __BLOB_T_DEFINED
945 struct BLOB {
946 	ULONG cbSize;
947 	BYTE* pBlobData;
948 }
949 
950 alias BLOB* PBLOB, LPBLOB;
951 //#endif
952 
953 struct WSAQUERYSETA
954 {
955 	DWORD         dwSize;
956 	LPSTR         lpszServiceInstanceName;
957 	LPGUID        lpServiceClassId;
958 	LPWSAVERSION  lpVersion;
959 	LPSTR         lpszComment;
960 	DWORD         dwNameSpace;
961 	LPGUID        lpNSProviderId;
962 	LPSTR         lpszContext;
963 	DWORD         dwNumberOfProtocols;
964 	LPAFPROTOCOLS lpafpProtocols;
965 	LPSTR         lpszQueryString;
966 	DWORD         dwNumberOfCsAddrs;
967 	LPCSADDR_INFO lpcsaBuffer;
968 	DWORD         dwOutputFlags;
969 	LPBLOB        lpBlob;
970 }
971 
972 alias WSAQUERYSETA* PWSAQUERYSETA, LPWSAQUERYSETA;
973 
974 struct WSAQUERYSETW
975 {
976 	DWORD         dwSize;
977 	LPWSTR        lpszServiceInstanceName;
978 	LPGUID        lpServiceClassId;
979 	LPWSAVERSION  lpVersion;
980 	LPWSTR        lpszComment;
981 	DWORD         dwNameSpace;
982 	LPGUID        lpNSProviderId;
983 	LPWSTR        lpszContext;
984 	DWORD         dwNumberOfProtocols;
985 	LPAFPROTOCOLS lpafpProtocols;
986 	LPWSTR        lpszQueryString;
987 	DWORD         dwNumberOfCsAddrs;
988 	LPCSADDR_INFO lpcsaBuffer;
989 	DWORD         dwOutputFlags;
990 	LPBLOB        lpBlob;
991 }
992 
993 
994 alias WSAQUERYSETW* PWSAQUERYSETW, LPWSAQUERYSETW;
995 
996 version(Unicode) {
997 	alias WSAQUERYSETW WSAQUERYSET;
998 	alias PWSAQUERYSETW PWSAQUERYSET;
999 	alias LPWSAQUERYSETW LPWSAQUERYSET;
1000 } else {
1001 	alias WSAQUERYSETA WSAQUERYSET;
1002 	alias PWSAQUERYSETA PWSAQUERYSET;
1003 	alias LPWSAQUERYSETA LPWSAQUERYSET;
1004 }
1005 
1006 const int
1007 	LUP_DEEP                = 0x0001,
1008 	LUP_CONTAINERS          = 0x0002,
1009 	LUP_NOCONTAINERS        = 0x0004,
1010 	LUP_NEAREST             = 0x0008,
1011 	LUP_RETURN_NAME         = 0x0010,
1012 	LUP_RETURN_TYPE         = 0x0020,
1013 	LUP_RETURN_VERSION      = 0x0040,
1014 	LUP_RETURN_COMMENT      = 0x0080,
1015 	LUP_RETURN_ADDR         = 0x0100,
1016 	LUP_RETURN_BLOB         = 0x0200,
1017 	LUP_RETURN_ALIASES      = 0x0400,
1018 	LUP_RETURN_QUERY_STRING = 0x0800,
1019 	LUP_RETURN_ALL          = 0x0FF0,
1020 	LUP_RES_SERVICE         = 0x8000,
1021 	LUP_FLUSHCACHE          = 0x1000,
1022 	LUP_FLUSHPREVIOUS       = 0x2000;
1023 
1024 struct WSANSCLASSINFOA
1025 {
1026 	LPSTR  lpszName;
1027 	DWORD  dwNameSpace;
1028 	DWORD  dwValueType;
1029 	DWORD  dwValueSize;
1030 	LPVOID lpValue;
1031 }
1032 
1033 alias WSANSCLASSINFOA* PWSANSCLASSINFOA, LPWSANSCLASSINFOA;
1034 
1035 struct WSANSCLASSINFOW
1036 {
1037 	LPWSTR lpszName;
1038 	DWORD  dwNameSpace;
1039 	DWORD  dwValueType;
1040 	DWORD  dwValueSize;
1041 	LPVOID lpValue;
1042 }
1043 
1044 alias WSANSCLASSINFOW* PWSANSCLASSINFOW, LPWSANSCLASSINFOW;
1045 
1046 version(Unicode) {
1047 	alias WSANSCLASSINFOW WSANSCLASSINFO;
1048 	alias PWSANSCLASSINFOW PWSANSCLASSINFO;
1049 	alias LPWSANSCLASSINFOW LPWSANSCLASSINFO;
1050 } else {
1051 	alias WSANSCLASSINFOA WSANSCLASSINFO;
1052 	alias PWSANSCLASSINFOA PWSANSCLASSINFO;
1053 	alias LPWSANSCLASSINFOA LPWSANSCLASSINFO;
1054 }
1055 
1056 struct WSASERVICECLASSINFOA
1057 {
1058 	LPGUID            lpServiceClassId;
1059 	LPSTR             lpszServiceClassName;
1060 	DWORD             dwCount;
1061 	LPWSANSCLASSINFOA lpClassInfos;
1062 }
1063 
1064 alias WSASERVICECLASSINFOA* PWSASERVICECLASSINFOA, LPWSASERVICECLASSINFOA;
1065 
1066 struct WSASERVICECLASSINFOW
1067 {
1068 	LPGUID            lpServiceClassId;
1069 	LPWSTR            lpszServiceClassName;
1070 	DWORD             dwCount;
1071 	LPWSANSCLASSINFOW lpClassInfos;
1072 }
1073 
1074 alias WSASERVICECLASSINFOW* PWSASERVICECLASSINFOW, LPWSASERVICECLASSINFOW;
1075 
1076 version(Unicode) {
1077 	alias WSASERVICECLASSINFOW WSASERVICECLASSINFO;
1078 	alias PWSASERVICECLASSINFOW PWSASERVICECLASSINFO;
1079 	alias LPWSASERVICECLASSINFOW LPWSASERVICECLASSINFO;
1080 } else {
1081 	alias WSASERVICECLASSINFOA WSASERVICECLASSINFO;
1082 	alias PWSASERVICECLASSINFOA PWSASERVICECLASSINFO;
1083 	alias LPWSASERVICECLASSINFOA LPWSASERVICECLASSINFO;
1084 }
1085 
1086 struct WSANAMESPACE_INFOA {
1087 	GUID  NSProviderId;
1088 	DWORD dwNameSpace;
1089 	BOOL  fActive;
1090 	DWORD dwVersion;
1091 	LPSTR lpszIdentifier;
1092 }
1093 
1094 alias WSANAMESPACE_INFOA* PWSANAMESPACE_INFOA, LPWSANAMESPACE_INFOA;
1095 
1096 struct WSANAMESPACE_INFOW {
1097 	GUID   NSProviderId;
1098 	DWORD  dwNameSpace;
1099 	BOOL   fActive;
1100 	DWORD  dwVersion;
1101 	LPWSTR lpszIdentifier;
1102 }
1103 
1104 alias WSANAMESPACE_INFOW* PWSANAMESPACE_INFOW, LPWSANAMESPACE_INFOW;
1105 
1106 version(Unicode) {
1107 	alias WSANAMESPACE_INFOW WSANAMESPACE_INFO;
1108 	alias PWSANAMESPACE_INFOW PWSANAMESPACE_INFO;
1109 	alias LPWSANAMESPACE_INFOW LPWSANAMESPACE_INFO;
1110 } else {
1111 	alias WSANAMESPACE_INFOA WSANAMESPACE_INFO;
1112 	alias PWSANAMESPACE_INFOA PWSANAMESPACE_INFO;
1113 	alias LPWSANAMESPACE_INFOA LPWSANAMESPACE_INFO;
1114 }
1115 
1116 struct WSAPROTOCOLCHAIN {
1117 	int                       ChainLen;
1118 	DWORD[MAX_PROTOCOL_CHAIN] ChainEntries;
1119 }
1120 
1121 alias WSAPROTOCOLCHAIN* LPWSAPROTOCOLCHAIN;
1122 
1123 const WSAPROTOCOL_LEN = 255;
1124 
1125 struct WSAPROTOCOL_INFOA {
1126 	DWORD dwServiceFlags1;
1127 	DWORD dwServiceFlags2;
1128 	DWORD dwServiceFlags3;
1129 	DWORD dwServiceFlags4;
1130 	DWORD dwProviderFlags;
1131 	GUID ProviderId;
1132 	DWORD dwCatalogEntryId;
1133 	WSAPROTOCOLCHAIN ProtocolChain;
1134 	int iVersion;
1135 	int iAddressFamily;
1136 	int iMaxSockAddr;
1137 	int iMinSockAddr;
1138 	int iSocketType;
1139 	int iProtocol;
1140 	int iProtocolMaxOffset;
1141 	int iNetworkByteOrder;
1142 	int iSecurityScheme;
1143 	DWORD dwMessageSize;
1144 	DWORD dwProviderReserved;
1145 	CHAR[WSAPROTOCOL_LEN+1] szProtocol;
1146 }
1147 
1148 alias WSAPROTOCOL_INFOA* LPWSAPROTOCOL_INFOA;
1149 
1150 struct WSAPROTOCOL_INFOW {
1151 	DWORD dwServiceFlags1;
1152 	DWORD dwServiceFlags2;
1153 	DWORD dwServiceFlags3;
1154 	DWORD dwServiceFlags4;
1155 	DWORD dwProviderFlags;
1156 	GUID ProviderId;
1157 	DWORD dwCatalogEntryId;
1158 	WSAPROTOCOLCHAIN ProtocolChain;
1159 	int iVersion;
1160 	int iAddressFamily;
1161 	int iMaxSockAddr;
1162 	int iMinSockAddr;
1163 	int iSocketType;
1164 	int iProtocol;
1165 	int iProtocolMaxOffset;
1166 	int iNetworkByteOrder;
1167 	int iSecurityScheme;
1168 	DWORD dwMessageSize;
1169 	DWORD dwProviderReserved;
1170 	WCHAR[WSAPROTOCOL_LEN+1] szProtocol;
1171 }
1172 
1173 alias WSAPROTOCOL_INFOW* LPWSAPROTOCOL_INFOW;
1174 
1175 // TODO: Below fptr was defined as "CALLBACK" for linkage; is this right?
1176 extern(C) {
1177 	alias int function(LPWSABUF, LPWSABUF, LPQOS, LPQOS, LPWSABUF, LPWSABUF, GROUP *, DWORD) LPCONDITIONPROC;
1178 }
1179 
1180 extern(Windows) {
1181 	alias void function(DWORD, DWORD, LPWSAOVERLAPPED, DWORD) LPWSAOVERLAPPED_COMPLETION_ROUTINE;
1182 }
1183 
1184 version(Unicode) {
1185 	alias WSAPROTOCOL_INFOW WSAPROTOCOL_INFO;
1186 	alias LPWSAPROTOCOL_INFOW LPWSAPROTOCOL_INFO;
1187 } else {
1188 	alias WSAPROTOCOL_INFOA WSAPROTOCOL_INFO;
1189 	alias LPWSAPROTOCOL_INFOA LPWSAPROTOCOL_INFO;
1190 }
1191 
1192 /* Needed for XP & .NET Server function WSANSPIoctl.  */
1193 enum WSACOMPLETIONTYPE {
1194     NSP_NOTIFY_IMMEDIATELY = 0,
1195     NSP_NOTIFY_HWND,
1196     NSP_NOTIFY_EVENT,
1197     NSP_NOTIFY_PORT,
1198     NSP_NOTIFY_APC
1199 }
1200 
1201 alias WSACOMPLETIONTYPE* PWSACOMPLETIONTYPE, LPWSACOMPLETIONTYPE;
1202 
1203 struct WSACOMPLETION {
1204     WSACOMPLETIONTYPE Type;
1205     union WSACOMPLETION_PARAMETERS {
1206         struct WSACOMPLETION_WINDOWMESSAGE {
1207             HWND hWnd;
1208             UINT uMsg;
1209             WPARAM context;
1210         }
1211 		WSACOMPLETION_WINDOWMESSAGE WindowMessage;
1212         struct WSACOMPLETION_EVENT {
1213             LPWSAOVERLAPPED lpOverlapped;
1214         }
1215 		WSACOMPLETION_EVENT Event;
1216         struct WSACOMPLETION_APC {
1217             LPWSAOVERLAPPED lpOverlapped;
1218             LPWSAOVERLAPPED_COMPLETION_ROUTINE lpfnCompletionProc;
1219         }
1220 		WSACOMPLETION_APC Apc;
1221         struct WSACOMPLETION_PORT {
1222             LPWSAOVERLAPPED lpOverlapped;
1223             HANDLE hPort;
1224             ULONG_PTR Key;
1225         }
1226 		WSACOMPLETION_PORT Port;
1227     }
1228 	WSACOMPLETION_PARAMETERS Parameters;
1229 }
1230 
1231 alias WSACOMPLETION* PWSACOMPLETION, LPWSACOMPLETION;
1232 
1233 const int
1234 	PFL_MULTIPLE_PROTO_ENTRIES  = 0x00000001,
1235 	PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002,
1236 	PFL_HIDDEN                  = 0x00000004,
1237 	PFL_MATCHES_PROTOCOL_ZERO   = 0x00000008;
1238 
1239 const int
1240 	XP1_CONNECTIONLESS           = 0x00000001,
1241 	XP1_GUARANTEED_DELIVERY      = 0x00000002,
1242 	XP1_GUARANTEED_ORDER         = 0x00000004,
1243 	XP1_MESSAGE_ORIENTED         = 0x00000008,
1244 	XP1_PSEUDO_STREAM            = 0x00000010,
1245 	XP1_GRACEFUL_CLOSE           = 0x00000020,
1246 	XP1_EXPEDITED_DATA           = 0x00000040,
1247 	XP1_CONNECT_DATA             = 0x00000080,
1248 	XP1_DISCONNECT_DATA          = 0x00000100,
1249 	XP1_SUPPORT_BROADCAST        = 0x00000200,
1250 	XP1_SUPPORT_MULTIPOINT       = 0x00000400,
1251 	XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800,
1252 	XP1_MULTIPOINT_DATA_PLANE    = 0x00001000,
1253 	XP1_QOS_SUPPORTED            = 0x00002000,
1254 	XP1_INTERRUPT                = 0x00004000,
1255 	XP1_UNI_SEND                 = 0x00008000,
1256 	XP1_UNI_RECV                 = 0x00010000,
1257 	XP1_IFS_HANDLES              = 0x00020000,
1258 	XP1_PARTIAL_MESSAGE          = 0x00040000;
1259 
1260 enum : int {
1261 	BIGENDIAN    = 0x0000,
1262 	LITTLEENDIAN = 0x0001
1263 }
1264 
1265 const SECURITY_PROTOCOL_NONE = 0x0000;
1266 
1267 const JL_SENDER_ONLY = 0x01;
1268 const JL_RECEIVER_ONLY = 0x02;
1269 const JL_BOTH = 0x04;
1270 
1271 const WSA_FLAG_OVERLAPPED = 0x01;
1272 const WSA_FLAG_MULTIPOINT_C_ROOT = 0x02;
1273 const WSA_FLAG_MULTIPOINT_C_LEAF = 0x04;
1274 const WSA_FLAG_MULTIPOINT_D_ROOT = 0x08;
1275 const WSA_FLAG_MULTIPOINT_D_LEAF = 0x10;
1276 
1277 const int IOC_UNIX = 0x00000000;
1278 const int IOC_WS2 = 0x08000000;
1279 const int IOC_PROTOCOL = 0x10000000;
1280 const int IOC_VENDOR = 0x18000000;
1281 
1282 template _WSAIO(int x, int y) { const int _WSAIO = IOC_VOID | x | y; }
1283 template _WSAIOR(int x, int y) { const int _WSAIOR = IOC_OUT | x | y; }
1284 template _WSAIOW(int x, int y) { const int _WSAIOW = IOC_IN | x | y; }
1285 template _WSAIORW(int x, int y) { const int _WSAIORW = IOC_INOUT | x | y; }
1286 
1287 const int SIO_ASSOCIATE_HANDLE               = _WSAIOW!(IOC_WS2,1);
1288 const int SIO_ENABLE_CIRCULAR_QUEUEING       = _WSAIO!(IOC_WS2,2);
1289 const int SIO_FIND_ROUTE                     = _WSAIOR!(IOC_WS2,3);
1290 const int SIO_FLUSH                          = _WSAIO!(IOC_WS2,4);
1291 const int SIO_GET_BROADCAST_ADDRESS          = _WSAIOR!(IOC_WS2,5);
1292 const int SIO_GET_EXTENSION_FUNCTION_POINTER = _WSAIORW!(IOC_WS2,6);
1293 const int SIO_GET_QOS                        = _WSAIORW!(IOC_WS2,7);
1294 const int SIO_GET_GROUP_QOS                  = _WSAIORW!(IOC_WS2,8);
1295 const int SIO_MULTIPOINT_LOOPBACK            = _WSAIOW!(IOC_WS2,9);
1296 const int SIO_MULTICAST_SCOPE                = _WSAIOW!(IOC_WS2,10);
1297 const int SIO_SET_QOS                        = _WSAIOW!(IOC_WS2,11);
1298 const int SIO_SET_GROUP_QOS                  = _WSAIOW!(IOC_WS2,12);
1299 const int SIO_TRANSLATE_HANDLE               = _WSAIORW!(IOC_WS2,13);
1300 const int SIO_ROUTING_INTERFACE_QUERY        = _WSAIORW!(IOC_WS2,20);
1301 const int SIO_ROUTING_INTERFACE_CHANGE       = _WSAIOW!(IOC_WS2,21);
1302 const int SIO_ADDRESS_LIST_QUERY             = _WSAIOR!(IOC_WS2,22);
1303 const int SIO_ADDRESS_LIST_CHANGE            = _WSAIO!(IOC_WS2,23);
1304 const int SIO_QUERY_TARGET_PNP_HANDLE        = _WSAIOR!(IOC_WS2,24);
1305 const int SIO_NSP_NOTIFY_CHANGE              = _WSAIOW!(IOC_WS2,25);
1306 
1307 const int TH_NETDEV = 1;
1308 const int TH_TAPI   = 2;
1309 
1310 
1311 extern(Windows) {
1312 	SOCKET WSAAccept(SOCKET, SOCKADDR*, LPINT, LPCONDITIONPROC, DWORD);
1313 	INT WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD);
1314 	INT WSAAddressToStringW(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOW, LPWSTR, LPDWORD);
1315 	BOOL WSACloseEvent(WSAEVENT);
1316 	int WSAConnect(SOCKET, const(SOCKADDR)*, int, LPWSABUF, LPWSABUF, LPQOS, LPQOS);
1317 	WSAEVENT WSACreateEvent();
1318 	int WSADuplicateSocketA(SOCKET, DWORD, LPWSAPROTOCOL_INFOA);
1319 	int WSADuplicateSocketW(SOCKET, DWORD, LPWSAPROTOCOL_INFOW);
1320 	INT WSAEnumNameSpaceProvidersA(LPDWORD, LPWSANAMESPACE_INFOA);
1321 	INT WSAEnumNameSpaceProvidersW(LPDWORD, LPWSANAMESPACE_INFOW);
1322 	int WSAEnumNetworkEvents(SOCKET, WSAEVENT, LPWSANETWORKEVENTS);
1323 	int WSAEnumProtocolsA(LPINT, LPWSAPROTOCOL_INFOA, LPDWORD);
1324 	int WSAEnumProtocolsW(LPINT, LPWSAPROTOCOL_INFOW, LPDWORD);
1325 	int WSAEventSelect(SOCKET, WSAEVENT, int);
1326 	BOOL WSAGetOverlappedResult(SOCKET, LPWSAOVERLAPPED, LPDWORD, BOOL, LPDWORD);
1327 	BOOL WSAGetQOSByName(SOCKET, LPWSABUF, LPQOS);
1328 	INT WSAGetServiceClassInfoA(LPGUID, LPGUID, LPDWORD, LPWSASERVICECLASSINFOA);
1329 	INT WSAGetServiceClassInfoW(LPGUID, LPGUID, LPDWORD, LPWSASERVICECLASSINFOW);
1330 	INT WSAGetServiceClassNameByClassIdA(LPGUID, LPSTR, LPDWORD);
1331 	INT WSAGetServiceClassNameByClassIdW(LPGUID, LPWSTR, LPDWORD);
1332 	int WSAHtonl(SOCKET, uint, uint*);
1333 	int WSAHtons(SOCKET, ushort, ushort*);
1334 	INT WSAInstallServiceClassA(LPWSASERVICECLASSINFOA);
1335 	INT WSAInstallServiceClassW(LPWSASERVICECLASSINFOW);
1336 	int WSAIoctl(SOCKET, DWORD, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
1337 	SOCKET WSAJoinLeaf(SOCKET, const(SOCKADDR)*, int, LPWSABUF, LPWSABUF, LPQOS, LPQOS, DWORD);
1338 	INT WSALookupServiceBeginA(LPWSAQUERYSETA, DWORD, LPHANDLE);
1339 	INT WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions, DWORD, LPHANDLE);
1340 	INT WSALookupServiceNextA(HANDLE, DWORD, LPDWORD, LPWSAQUERYSETA);
1341 	INT WSALookupServiceNextW(HANDLE, DWORD, LPDWORD, LPWSAQUERYSETW);
1342 	INT WSALookupServiceEnd(HANDLE);
1343 	int WSANSPIoctl(HANDLE,DWORD,LPVOID,DWORD,LPVOID,DWORD,LPDWORD,LPWSACOMPLETION); /* XP or .NET Server */
1344 	int WSANtohl(SOCKET, uint, uint*);
1345 	int WSANtohs(SOCKET, ushort, ushort*);
1346 	int WSARecv(SOCKET, LPWSABUF, DWORD, LPDWORD, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
1347 	int WSARecvDisconnect(SOCKET, LPWSABUF);
1348 	int WSARecvFrom(SOCKET, LPWSABUF, DWORD, LPDWORD, LPDWORD, SOCKADDR*, LPINT, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
1349 	INT WSARemoveServiceClass(LPGUID);
1350 	BOOL WSAResetEvent(WSAEVENT);
1351 	int WSASend(SOCKET, LPWSABUF, DWORD, LPDWORD, DWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
1352 	int WSASendDisconnect(SOCKET, LPWSABUF);
1353 	int WSASendTo(SOCKET, LPWSABUF, DWORD, LPDWORD, DWORD, const(SOCKADDR)*, int, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
1354 	BOOL WSASetEvent(WSAEVENT);
1355 	INT WSASetServiceA(LPWSAQUERYSETA, WSAESETSERVICEOP, DWORD); // NB: was declared with "WSAAPI" linkage
1356 	INT WSASetServiceW(LPWSAQUERYSETW, WSAESETSERVICEOP, DWORD);
1357 	SOCKET WSASocketA(int, int, int, LPWSAPROTOCOL_INFOA, GROUP, DWORD);
1358 	SOCKET WSASocketW(int, int, int, LPWSAPROTOCOL_INFOW, GROUP, DWORD);
1359 	INT WSAStringToAddressA(LPSTR, INT, LPWSAPROTOCOL_INFOA, LPSOCKADDR, LPINT);
1360 	INT WSAStringToAddressW(LPWSTR, INT, LPWSAPROTOCOL_INFOW, LPSOCKADDR, LPINT);
1361 	DWORD WSAWaitForMultipleEvents(DWORD, const(WSAEVENT)*, BOOL, DWORD, BOOL);
1362 
1363 	alias typeof(&WSAAccept) LPFN_WSAACCEPT;
1364 	alias typeof(&WSAAddressToStringA) LPFN_WSAADDRESSTOSTRINGA;
1365 	alias typeof(&WSAAddressToStringW) LPFN_WSAADDRESSTOSTRINGW;
1366 	alias typeof(&WSACloseEvent) LPFN_WSACLOSEEVENT;
1367 	alias typeof(&WSAConnect) LPFN_WSACONNECT;
1368 	alias typeof(&WSACreateEvent) LPFN_WSACREATEEVENT;
1369 	alias typeof(&WSADuplicateSocketA) LPFN_WSADUPLICATESOCKETA;
1370 	alias typeof(&WSADuplicateSocketW) LPFN_WSADUPLICATESOCKETW;
1371 	alias typeof(&WSAEnumNameSpaceProvidersA) LPFN_WSAENUMNAMESPACEPROVIDERSA;
1372 	alias typeof(&WSAEnumNameSpaceProvidersW) LPFN_WSAENUMNAMESPACEPROVIDERSW;
1373 	alias typeof(&WSAEnumNetworkEvents) LPFN_WSAENUMNETWORKEVENTS;
1374 	alias typeof(&WSAEnumProtocolsA) LPFN_WSAENUMPROTOCOLSA;
1375 	alias typeof(&WSAEnumProtocolsW) LPFN_WSAENUMPROTOCOLSW;
1376 	alias typeof(&WSAEventSelect) LPFN_WSAEVENTSELECT;
1377 	alias typeof(&WSAGetOverlappedResult) LPFN_WSAGETOVERLAPPEDRESULT;
1378 	alias typeof(&WSAGetQOSByName) LPFN_WSAGETQOSBYNAME;
1379 	alias typeof(&WSAGetServiceClassInfoA) LPFN_WSAGETSERVICECLASSINFOA;
1380 	alias typeof(&WSAGetServiceClassInfoW) LPFN_WSAGETSERVICECLASSINFOW;
1381 	alias typeof(&WSAGetServiceClassNameByClassIdA) LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA;
1382 	alias typeof(&WSAGetServiceClassNameByClassIdW) LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW;
1383 	alias typeof(&WSAHtonl) LPFN_WSAHTONL;
1384 	alias typeof(&WSAHtons) LPFN_WSAHTONS;
1385 	alias typeof(&WSAInstallServiceClassA) LPFN_WSAINSTALLSERVICECLASSA;
1386 	alias typeof(&WSAInstallServiceClassW) LPFN_WSAINSTALLSERVICECLASSW;
1387 	alias typeof(&WSAIoctl) LPFN_WSAIOCTL;
1388 	alias typeof(&WSAJoinLeaf) LPFN_WSAJOINLEAF;
1389 	alias typeof(&WSALookupServiceBeginA) LPFN_WSALOOKUPSERVICEBEGINA;
1390 	alias typeof(&WSALookupServiceBeginW) LPFN_WSALOOKUPSERVICEBEGINW;
1391 	alias typeof(&WSALookupServiceNextA) LPFN_WSALOOKUPSERVICENEXTA;
1392 	alias typeof(&WSALookupServiceNextW) LPFN_WSALOOKUPSERVICENEXTW;
1393 	alias typeof(&WSALookupServiceEnd) LPFN_WSALOOKUPSERVICEEND;
1394 	alias typeof(&WSANSPIoctl) LPFN_WSANSPIoctl;
1395 	alias typeof(&WSANtohl) LPFN_WSANTOHL;
1396 	alias typeof(&WSANtohs) LPFN_WSANTOHS;
1397 	alias typeof(&WSARecv) LPFN_WSARECV;
1398 	alias typeof(&WSARecvDisconnect) LPFN_WSARECVDISCONNECT;
1399 	alias typeof(&WSARecvFrom) LPFN_WSARECVFROM;
1400 	alias typeof(&WSARemoveServiceClass) LPFN_WSAREMOVESERVICECLASS;
1401 	alias typeof(&WSAResetEvent) LPFN_WSARESETEVENT;
1402 	alias typeof(&WSASend) LPFN_WSASEND;
1403 	alias typeof(&WSASendDisconnect) LPFN_WSASENDDISCONNECT;
1404 	alias typeof(&WSASendTo) LPFN_WSASENDTO;
1405 	alias typeof(&WSASetEvent) LPFN_WSASETEVENT;
1406 	alias typeof(&WSASetServiceA) LPFN_WSASETSERVICEA;
1407 	alias typeof(&WSASetServiceW) LPFN_WSASETSERVICEW;
1408 	alias typeof(&WSASocketA) LPFN_WSASOCKETA;
1409 	alias typeof(&WSASocketW) LPFN_WSASOCKETW;
1410 	alias typeof(&WSAStringToAddressA) LPFN_WSASTRINGTOADDRESSA;
1411 	alias typeof(&WSAStringToAddressW) LPFN_WSASTRINGTOADDRESSW;
1412 	alias typeof(&WSAWaitForMultipleEvents) LPFN_WSAWAITFORMULTIPLEEVENTS;
1413 }
1414 
1415 version(Unicode) {
1416 	alias LPFN_WSAADDRESSTOSTRINGW LPFN_WSAADDRESSTOSTRING;
1417 	alias LPFN_WSADUPLICATESOCKETW LPFN_WSADUPLICATESOCKET;
1418 	alias LPFN_WSAENUMNAMESPACEPROVIDERSW LPFN_WSAENUMNAMESPACEPROVIDERS;
1419 	alias LPFN_WSAENUMPROTOCOLSW LPFN_WSAENUMPROTOCOLS;
1420 	alias LPFN_WSAGETSERVICECLASSINFOW LPFN_WSAGETSERVICECLASSINFO;
1421 	alias LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW LPFN_WSAGETSERVICECLASSNAMEBYCLASSID;
1422 	alias LPFN_WSAINSTALLSERVICECLASSW LPFN_WSAINSTALLSERVICECLASS;
1423 	alias LPFN_WSALOOKUPSERVICEBEGINW LPFN_WSALOOKUPSERVICEBEGIN;
1424 	alias LPFN_WSALOOKUPSERVICENEXTW LPFN_WSALOOKUPSERVICENEXT;
1425 	alias LPFN_WSASETSERVICEW LPFN_WSASETSERVICE;
1426 	alias LPFN_WSASOCKETW LPFN_WSASOCKET;
1427 	alias LPFN_WSASTRINGTOADDRESSW LPFN_WSASTRINGTOADDRESS;
1428 	alias WSAAddressToStringW WSAAddressToString;
1429 	alias WSADuplicateSocketW WSADuplicateSocket;
1430 	alias WSAEnumNameSpaceProvidersW WSAEnumNameSpaceProviders;
1431 	alias WSAEnumProtocolsW WSAEnumProtocols;
1432 	alias WSAGetServiceClassInfoW WSAGetServiceClassInfo;
1433 	alias WSAGetServiceClassNameByClassIdW WSAGetServiceClassNameByClassId;
1434 	alias WSASetServiceW WSASetService;
1435 	alias WSASocketW WSASocket;
1436 	alias WSAStringToAddressW WSAStringToAddress;
1437 	alias WSALookupServiceBeginW WSALookupServiceBegin;
1438 	alias WSALookupServiceNextW WSALookupServiceNext;
1439 	alias WSAInstallServiceClassW WSAInstallServiceClass;
1440 } else {
1441 	alias LPFN_WSAADDRESSTOSTRINGA LPFN_WSAADDRESSTOSTRING;
1442 	alias LPFN_WSADUPLICATESOCKETW LPFN_WSADUPLICATESOCKET;
1443 	alias LPFN_WSAENUMNAMESPACEPROVIDERSA LPFN_WSAENUMNAMESPACEPROVIDERS;
1444 	alias LPFN_WSAENUMPROTOCOLSA LPFN_WSAENUMPROTOCOLS;
1445 	alias LPFN_WSAGETSERVICECLASSINFOA LPFN_WSAGETSERVICECLASSINFO;
1446 	alias LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA LPFN_WSAGETSERVICECLASSNAMEBYCLASSID;
1447 	alias LPFN_WSAINSTALLSERVICECLASSA LPFN_WSAINSTALLSERVICECLASS;
1448 	alias LPFN_WSALOOKUPSERVICEBEGINA LPFN_WSALOOKUPSERVICEBEGIN;
1449 	alias LPFN_WSALOOKUPSERVICENEXTA LPFN_WSALOOKUPSERVICENEXT;
1450 	alias LPFN_WSASETSERVICEA LPFN_WSASETSERVICE;
1451 	alias LPFN_WSASOCKETA LPFN_WSASOCKET;
1452 	alias LPFN_WSASTRINGTOADDRESSA LPFN_WSASTRINGTOADDRESS;
1453 	alias WSAAddressToStringA WSAAddressToString;
1454 	alias WSADuplicateSocketA WSADuplicateSocket;
1455 	alias WSAEnumNameSpaceProvidersA WSAEnumNameSpaceProviders;
1456 	alias WSAEnumProtocolsA WSAEnumProtocols;
1457 	alias WSAGetServiceClassInfoA WSAGetServiceClassInfo;
1458 	alias WSAGetServiceClassNameByClassIdA WSAGetServiceClassNameByClassId;
1459 	alias WSAInstallServiceClassA WSAInstallServiceClass;
1460 	alias WSALookupServiceBeginA WSALookupServiceBegin;
1461 	alias WSALookupServiceNextA WSALookupServiceNext;
1462 	alias WSASocketA WSASocket;
1463 	alias WSAStringToAddressA WSAStringToAddress;
1464 	alias WSASetServiceA WSASetService;
1465 }