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