1const std = @import("../../std.zig");
2const windows = std.os.windows;
3
4const WINAPI = windows.WINAPI;
5const OVERLAPPED = windows.OVERLAPPED;
6const WORD = windows.WORD;
7const DWORD = windows.DWORD;
8const GUID = windows.GUID;
9const USHORT = windows.USHORT;
10const WCHAR = windows.WCHAR;
11const BOOL = windows.BOOL;
12const HANDLE = windows.HANDLE;
13const timeval = windows.timeval;
14const HWND = windows.HWND;
15const INT = windows.INT;
16const SHORT = windows.SHORT;
17const CHAR = windows.CHAR;
18const ULONG = windows.ULONG;
19const LPARAM = windows.LPARAM;
20const FARPROC = windows.FARPROC;
21
22pub const SOCKET = *opaque {};
23pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
24
25pub const GROUP = u32;
26pub const ADDRESS_FAMILY = u16;
27pub const WSAEVENT = HANDLE;
28
29// Microsoft use the signed c_int for this, but it should never be negative
30pub const socklen_t = u32;
31
32pub const LM_HB_Extension = 128;
33pub const LM_HB1_PnP = 1;
34pub const LM_HB1_PDA_Palmtop = 2;
35pub const LM_HB1_Computer = 4;
36pub const LM_HB1_Printer = 8;
37pub const LM_HB1_Modem = 16;
38pub const LM_HB1_Fax = 32;
39pub const LM_HB1_LANAccess = 64;
40pub const LM_HB2_Telephony = 1;
41pub const LM_HB2_FileServer = 2;
42pub const ATMPROTO_AALUSER = 0;
43pub const ATMPROTO_AAL1 = 1;
44pub const ATMPROTO_AAL2 = 2;
45pub const ATMPROTO_AAL34 = 3;
46pub const ATMPROTO_AAL5 = 5;
47pub const SAP_FIELD_ABSENT = 4294967294;
48pub const SAP_FIELD_ANY = 4294967295;
49pub const SAP_FIELD_ANY_AESA_SEL = 4294967290;
50pub const SAP_FIELD_ANY_AESA_REST = 4294967291;
51pub const ATM_E164 = 1;
52pub const ATM_NSAP = 2;
53pub const ATM_AESA = 2;
54pub const ATM_ADDR_SIZE = 20;
55pub const BLLI_L2_ISO_1745 = 1;
56pub const BLLI_L2_Q921 = 2;
57pub const BLLI_L2_X25L = 6;
58pub const BLLI_L2_X25M = 7;
59pub const BLLI_L2_ELAPB = 8;
60pub const BLLI_L2_HDLC_ARM = 9;
61pub const BLLI_L2_HDLC_NRM = 10;
62pub const BLLI_L2_HDLC_ABM = 11;
63pub const BLLI_L2_LLC = 12;
64pub const BLLI_L2_X75 = 13;
65pub const BLLI_L2_Q922 = 14;
66pub const BLLI_L2_USER_SPECIFIED = 16;
67pub const BLLI_L2_ISO_7776 = 17;
68pub const BLLI_L3_X25 = 6;
69pub const BLLI_L3_ISO_8208 = 7;
70pub const BLLI_L3_X223 = 8;
71pub const BLLI_L3_SIO_8473 = 9;
72pub const BLLI_L3_T70 = 10;
73pub const BLLI_L3_ISO_TR9577 = 11;
74pub const BLLI_L3_USER_SPECIFIED = 16;
75pub const BLLI_L3_IPI_SNAP = 128;
76pub const BLLI_L3_IPI_IP = 204;
77pub const BHLI_ISO = 0;
78pub const BHLI_UserSpecific = 1;
79pub const BHLI_HighLayerProfile = 2;
80pub const BHLI_VendorSpecificAppId = 3;
81pub const AAL5_MODE_MESSAGE = 1;
82pub const AAL5_MODE_STREAMING = 2;
83pub const AAL5_SSCS_NULL = 0;
84pub const AAL5_SSCS_SSCOP_ASSURED = 1;
85pub const AAL5_SSCS_SSCOP_NON_ASSURED = 2;
86pub const AAL5_SSCS_FRAME_RELAY = 4;
87pub const BCOB_A = 1;
88pub const BCOB_C = 3;
89pub const BCOB_X = 16;
90pub const TT_NOIND = 0;
91pub const TT_CBR = 4;
92pub const TT_VBR = 8;
93pub const TR_NOIND = 0;
94pub const TR_END_TO_END = 1;
95pub const TR_NO_END_TO_END = 2;
96pub const CLIP_NOT = 0;
97pub const CLIP_SUS = 32;
98pub const UP_P2P = 0;
99pub const UP_P2MP = 1;
100pub const BLLI_L2_MODE_NORMAL = 64;
101pub const BLLI_L2_MODE_EXT = 128;
102pub const BLLI_L3_MODE_NORMAL = 64;
103pub const BLLI_L3_MODE_EXT = 128;
104pub const BLLI_L3_PACKET_16 = 4;
105pub const BLLI_L3_PACKET_32 = 5;
106pub const BLLI_L3_PACKET_64 = 6;
107pub const BLLI_L3_PACKET_128 = 7;
108pub const BLLI_L3_PACKET_256 = 8;
109pub const BLLI_L3_PACKET_512 = 9;
110pub const BLLI_L3_PACKET_1024 = 10;
111pub const BLLI_L3_PACKET_2048 = 11;
112pub const BLLI_L3_PACKET_4096 = 12;
113pub const PI_ALLOWED = 0;
114pub const PI_RESTRICTED = 64;
115pub const PI_NUMBER_NOT_AVAILABLE = 128;
116pub const SI_USER_NOT_SCREENED = 0;
117pub const SI_USER_PASSED = 1;
118pub const SI_USER_FAILED = 2;
119pub const SI_NETWORK = 3;
120pub const CAUSE_LOC_USER = 0;
121pub const CAUSE_LOC_PRIVATE_LOCAL = 1;
122pub const CAUSE_LOC_PUBLIC_LOCAL = 2;
123pub const CAUSE_LOC_TRANSIT_NETWORK = 3;
124pub const CAUSE_LOC_PUBLIC_REMOTE = 4;
125pub const CAUSE_LOC_PRIVATE_REMOTE = 5;
126pub const CAUSE_LOC_INTERNATIONAL_NETWORK = 7;
127pub const CAUSE_LOC_BEYOND_INTERWORKING = 10;
128pub const CAUSE_UNALLOCATED_NUMBER = 1;
129pub const CAUSE_NO_ROUTE_TO_TRANSIT_NETWORK = 2;
130pub const CAUSE_NO_ROUTE_TO_DESTINATION = 3;
131pub const CAUSE_VPI_VCI_UNACCEPTABLE = 10;
132pub const CAUSE_NORMAL_CALL_CLEARING = 16;
133pub const CAUSE_USER_BUSY = 17;
134pub const CAUSE_NO_USER_RESPONDING = 18;
135pub const CAUSE_CALL_REJECTED = 21;
136pub const CAUSE_NUMBER_CHANGED = 22;
137pub const CAUSE_USER_REJECTS_CLIR = 23;
138pub const CAUSE_DESTINATION_OUT_OF_ORDER = 27;
139pub const CAUSE_INVALID_NUMBER_FORMAT = 28;
140pub const CAUSE_STATUS_ENQUIRY_RESPONSE = 30;
141pub const CAUSE_NORMAL_UNSPECIFIED = 31;
142pub const CAUSE_VPI_VCI_UNAVAILABLE = 35;
143pub const CAUSE_NETWORK_OUT_OF_ORDER = 38;
144pub const CAUSE_TEMPORARY_FAILURE = 41;
145pub const CAUSE_ACCESS_INFORMAION_DISCARDED = 43;
146pub const CAUSE_NO_VPI_VCI_AVAILABLE = 45;
147pub const CAUSE_RESOURCE_UNAVAILABLE = 47;
148pub const CAUSE_QOS_UNAVAILABLE = 49;
149pub const CAUSE_USER_CELL_RATE_UNAVAILABLE = 51;
150pub const CAUSE_BEARER_CAPABILITY_UNAUTHORIZED = 57;
151pub const CAUSE_BEARER_CAPABILITY_UNAVAILABLE = 58;
152pub const CAUSE_OPTION_UNAVAILABLE = 63;
153pub const CAUSE_BEARER_CAPABILITY_UNIMPLEMENTED = 65;
154pub const CAUSE_UNSUPPORTED_TRAFFIC_PARAMETERS = 73;
155pub const CAUSE_INVALID_CALL_REFERENCE = 81;
156pub const CAUSE_CHANNEL_NONEXISTENT = 82;
157pub const CAUSE_INCOMPATIBLE_DESTINATION = 88;
158pub const CAUSE_INVALID_ENDPOINT_REFERENCE = 89;
159pub const CAUSE_INVALID_TRANSIT_NETWORK_SELECTION = 91;
160pub const CAUSE_TOO_MANY_PENDING_ADD_PARTY = 92;
161pub const CAUSE_AAL_PARAMETERS_UNSUPPORTED = 93;
162pub const CAUSE_MANDATORY_IE_MISSING = 96;
163pub const CAUSE_UNIMPLEMENTED_MESSAGE_TYPE = 97;
164pub const CAUSE_UNIMPLEMENTED_IE = 99;
165pub const CAUSE_INVALID_IE_CONTENTS = 100;
166pub const CAUSE_INVALID_STATE_FOR_MESSAGE = 101;
167pub const CAUSE_RECOVERY_ON_TIMEOUT = 102;
168pub const CAUSE_INCORRECT_MESSAGE_LENGTH = 104;
169pub const CAUSE_PROTOCOL_ERROR = 111;
170pub const CAUSE_COND_UNKNOWN = 0;
171pub const CAUSE_COND_PERMANENT = 1;
172pub const CAUSE_COND_TRANSIENT = 2;
173pub const CAUSE_REASON_USER = 0;
174pub const CAUSE_REASON_IE_MISSING = 4;
175pub const CAUSE_REASON_IE_INSUFFICIENT = 8;
176pub const CAUSE_PU_PROVIDER = 0;
177pub const CAUSE_PU_USER = 8;
178pub const CAUSE_NA_NORMAL = 0;
179pub const CAUSE_NA_ABNORMAL = 4;
180pub const QOS_CLASS0 = 0;
181pub const QOS_CLASS1 = 1;
182pub const QOS_CLASS2 = 2;
183pub const QOS_CLASS3 = 3;
184pub const QOS_CLASS4 = 4;
185pub const TNS_TYPE_NATIONAL = 64;
186pub const TNS_PLAN_CARRIER_ID_CODE = 1;
187pub const SIO_GET_NUMBER_OF_ATM_DEVICES = 1343619073;
188pub const SIO_GET_ATM_ADDRESS = 3491102722;
189pub const SIO_ASSOCIATE_PVC = 2417360899;
190pub const SIO_GET_ATM_CONNECTION_ID = 1343619076;
191pub const RIO_MSG_DONT_NOTIFY = 1;
192pub const RIO_MSG_DEFER = 2;
193pub const RIO_MSG_WAITALL = 4;
194pub const RIO_MSG_COMMIT_ONLY = 8;
195pub const RIO_MAX_CQ_SIZE = 134217728;
196pub const RIO_CORRUPT_CQ = 4294967295;
197pub const WINDOWS_AF_IRDA = 26;
198pub const WCE_AF_IRDA = 22;
199pub const IRDA_PROTO_SOCK_STREAM = 1;
200pub const IRLMP_ENUMDEVICES = 16;
201pub const IRLMP_IAS_SET = 17;
202pub const IRLMP_IAS_QUERY = 18;
203pub const IRLMP_SEND_PDU_LEN = 19;
204pub const IRLMP_EXCLUSIVE_MODE = 20;
205pub const IRLMP_IRLPT_MODE = 21;
206pub const IRLMP_9WIRE_MODE = 22;
207pub const IRLMP_TINYTP_MODE = 23;
208pub const IRLMP_PARAMETERS = 24;
209pub const IRLMP_DISCOVERY_MODE = 25;
210pub const IRLMP_SHARP_MODE = 32;
211pub const IAS_ATTRIB_NO_CLASS = 16;
212pub const IAS_ATTRIB_NO_ATTRIB = 0;
213pub const IAS_ATTRIB_INT = 1;
214pub const IAS_ATTRIB_OCTETSEQ = 2;
215pub const IAS_ATTRIB_STR = 3;
216pub const IAS_MAX_USER_STRING = 256;
217pub const IAS_MAX_OCTET_STRING = 1024;
218pub const IAS_MAX_CLASSNAME = 64;
219pub const IAS_MAX_ATTRIBNAME = 256;
220pub const LmCharSetASCII = 0;
221pub const LmCharSetISO_8859_1 = 1;
222pub const LmCharSetISO_8859_2 = 2;
223pub const LmCharSetISO_8859_3 = 3;
224pub const LmCharSetISO_8859_4 = 4;
225pub const LmCharSetISO_8859_5 = 5;
226pub const LmCharSetISO_8859_6 = 6;
227pub const LmCharSetISO_8859_7 = 7;
228pub const LmCharSetISO_8859_8 = 8;
229pub const LmCharSetISO_8859_9 = 9;
230pub const LmCharSetUNICODE = 255;
231pub const LM_BAUD_1200 = 1200;
232pub const LM_BAUD_2400 = 2400;
233pub const LM_BAUD_9600 = 9600;
234pub const LM_BAUD_19200 = 19200;
235pub const LM_BAUD_38400 = 38400;
236pub const LM_BAUD_57600 = 57600;
237pub const LM_BAUD_115200 = 115200;
238pub const LM_BAUD_576K = 576000;
239pub const LM_BAUD_1152K = 1152000;
240pub const LM_BAUD_4M = 4000000;
241pub const LM_BAUD_16M = 16000000;
242pub const IPX_PTYPE = 16384;
243pub const IPX_FILTERPTYPE = 16385;
244pub const IPX_STOPFILTERPTYPE = 16387;
245pub const IPX_DSTYPE = 16386;
246pub const IPX_EXTENDED_ADDRESS = 16388;
247pub const IPX_RECVHDR = 16389;
248pub const IPX_MAXSIZE = 16390;
249pub const IPX_ADDRESS = 16391;
250pub const IPX_GETNETINFO = 16392;
251pub const IPX_GETNETINFO_NORIP = 16393;
252pub const IPX_SPXGETCONNECTIONSTATUS = 16395;
253pub const IPX_ADDRESS_NOTIFY = 16396;
254pub const IPX_MAX_ADAPTER_NUM = 16397;
255pub const IPX_RERIPNETNUMBER = 16398;
256pub const IPX_RECEIVE_BROADCAST = 16399;
257pub const IPX_IMMEDIATESPXACK = 16400;
258pub const MAX_MCAST_TTL = 255;
259pub const RM_OPTIONSBASE = 1000;
260pub const RM_RATE_WINDOW_SIZE = 1001;
261pub const RM_SET_MESSAGE_BOUNDARY = 1002;
262pub const RM_FLUSHCACHE = 1003;
263pub const RM_SENDER_WINDOW_ADVANCE_METHOD = 1004;
264pub const RM_SENDER_STATISTICS = 1005;
265pub const RM_LATEJOIN = 1006;
266pub const RM_SET_SEND_IF = 1007;
267pub const RM_ADD_RECEIVE_IF = 1008;
268pub const RM_DEL_RECEIVE_IF = 1009;
269pub const RM_SEND_WINDOW_ADV_RATE = 1010;
270pub const RM_USE_FEC = 1011;
271pub const RM_SET_MCAST_TTL = 1012;
272pub const RM_RECEIVER_STATISTICS = 1013;
273pub const RM_HIGH_SPEED_INTRANET_OPT = 1014;
274pub const SENDER_DEFAULT_RATE_KBITS_PER_SEC = 56;
275pub const SENDER_DEFAULT_WINDOW_ADV_PERCENTAGE = 15;
276pub const MAX_WINDOW_INCREMENT_PERCENTAGE = 25;
277pub const SENDER_DEFAULT_LATE_JOINER_PERCENTAGE = 0;
278pub const SENDER_MAX_LATE_JOINER_PERCENTAGE = 75;
279pub const BITS_PER_BYTE = 8;
280pub const LOG2_BITS_PER_BYTE = 3;
281
282pub const SOCKET_DEFAULT2_QM_POLICY = GUID.parse("{aec2ef9c-3a4d-4d3e-8842-239942e39a47}");
283pub const REAL_TIME_NOTIFICATION_CAPABILITY = GUID.parse("{6b59819a-5cae-492d-a901-2a3c2c50164f}");
284pub const REAL_TIME_NOTIFICATION_CAPABILITY_EX = GUID.parse("{6843da03-154a-4616-a508-44371295f96b}");
285pub const ASSOCIATE_NAMERES_CONTEXT = GUID.parse("{59a38b67-d4fe-46e1-ba3c-87ea74ca3049}");
286
287pub const WSAID_CONNECTEX = GUID{
288    .Data1 = 0x25a207b9,
289    .Data2 = 0xddf3,
290    .Data3 = 0x4660,
291    .Data4 = [8]u8{ 0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e },
292};
293
294pub const WSAID_ACCEPTEX = GUID{
295    .Data1 = 0xb5367df1,
296    .Data2 = 0xcbac,
297    .Data3 = 0x11cf,
298    .Data4 = [8]u8{ 0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 },
299};
300
301pub const WSAID_GETACCEPTEXSOCKADDRS = GUID{
302    .Data1 = 0xb5367df2,
303    .Data2 = 0xcbac,
304    .Data3 = 0x11cf,
305    .Data4 = [8]u8{ 0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 },
306};
307
308pub const WSAID_WSARECVMSG = GUID{
309    .Data1 = 0xf689d7c8,
310    .Data2 = 0x6f1f,
311    .Data3 = 0x436b,
312    .Data4 = [8]u8{ 0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22 },
313};
314
315pub const WSAID_WSAPOLL = GUID{
316    .Data1 = 0x18C76F85,
317    .Data2 = 0xDC66,
318    .Data3 = 0x4964,
319    .Data4 = [8]u8{ 0x97, 0x2E, 0x23, 0xC2, 0x72, 0x38, 0x31, 0x2B },
320};
321
322pub const WSAID_WSASENDMSG = GUID{
323    .Data1 = 0xa441e712,
324    .Data2 = 0x754f,
325    .Data3 = 0x43ca,
326    .Data4 = [8]u8{ 0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d },
327};
328
329pub const TCP_INITIAL_RTO_DEFAULT_RTT = 0;
330pub const TCP_INITIAL_RTO_DEFAULT_MAX_SYN_RETRANSMISSIONS = 0;
331pub const SOCKET_SETTINGS_GUARANTEE_ENCRYPTION = 1;
332pub const SOCKET_SETTINGS_ALLOW_INSECURE = 2;
333pub const SOCKET_SETTINGS_IPSEC_SKIP_FILTER_INSTANTIATION = 1;
334pub const SOCKET_SETTINGS_IPSEC_OPTIONAL_PEER_NAME_VERIFICATION = 2;
335pub const SOCKET_SETTINGS_IPSEC_ALLOW_FIRST_INBOUND_PKT_UNENCRYPTED = 4;
336pub const SOCKET_SETTINGS_IPSEC_PEER_NAME_IS_RAW_FORMAT = 8;
337pub const SOCKET_QUERY_IPSEC2_ABORT_CONNECTION_ON_FIELD_CHANGE = 1;
338pub const SOCKET_QUERY_IPSEC2_FIELD_MASK_MM_SA_ID = 1;
339pub const SOCKET_QUERY_IPSEC2_FIELD_MASK_QM_SA_ID = 2;
340pub const SOCKET_INFO_CONNECTION_SECURED = 1;
341pub const SOCKET_INFO_CONNECTION_ENCRYPTED = 2;
342pub const SOCKET_INFO_CONNECTION_IMPERSONATED = 4;
343pub const IN4ADDR_LOOPBACK = 16777343;
344pub const IN4ADDR_LOOPBACKPREFIX_LENGTH = 8;
345pub const IN4ADDR_LINKLOCALPREFIX_LENGTH = 16;
346pub const IN4ADDR_MULTICASTPREFIX_LENGTH = 4;
347pub const IFF_UP = 1;
348pub const IFF_BROADCAST = 2;
349pub const IFF_LOOPBACK = 4;
350pub const IFF_POINTTOPOINT = 8;
351pub const IFF_MULTICAST = 16;
352pub const IP_OPTIONS = 1;
353pub const IP_HDRINCL = 2;
354pub const IP_TOS = 3;
355pub const IP_TTL = 4;
356pub const IP_MULTICAST_IF = 9;
357pub const IP_MULTICAST_TTL = 10;
358pub const IP_MULTICAST_LOOP = 11;
359pub const IP_ADD_MEMBERSHIP = 12;
360pub const IP_DROP_MEMBERSHIP = 13;
361pub const IP_DONTFRAGMENT = 14;
362pub const IP_ADD_SOURCE_MEMBERSHIP = 15;
363pub const IP_DROP_SOURCE_MEMBERSHIP = 16;
364pub const IP_BLOCK_SOURCE = 17;
365pub const IP_UNBLOCK_SOURCE = 18;
366pub const IP_PKTINFO = 19;
367pub const IP_HOPLIMIT = 21;
368pub const IP_RECVTTL = 21;
369pub const IP_RECEIVE_BROADCAST = 22;
370pub const IP_RECVIF = 24;
371pub const IP_RECVDSTADDR = 25;
372pub const IP_IFLIST = 28;
373pub const IP_ADD_IFLIST = 29;
374pub const IP_DEL_IFLIST = 30;
375pub const IP_UNICAST_IF = 31;
376pub const IP_RTHDR = 32;
377pub const IP_GET_IFLIST = 33;
378pub const IP_RECVRTHDR = 38;
379pub const IP_TCLASS = 39;
380pub const IP_RECVTCLASS = 40;
381pub const IP_RECVTOS = 40;
382pub const IP_ORIGINAL_ARRIVAL_IF = 47;
383pub const IP_ECN = 50;
384pub const IP_PKTINFO_EX = 51;
385pub const IP_WFP_REDIRECT_RECORDS = 60;
386pub const IP_WFP_REDIRECT_CONTEXT = 70;
387pub const IP_MTU_DISCOVER = 71;
388pub const IP_MTU = 73;
389pub const IP_NRT_INTERFACE = 74;
390pub const IP_RECVERR = 75;
391pub const IP_USER_MTU = 76;
392pub const IP_UNSPECIFIED_TYPE_OF_SERVICE = -1;
393pub const IN6ADDR_LINKLOCALPREFIX_LENGTH = 64;
394pub const IN6ADDR_MULTICASTPREFIX_LENGTH = 8;
395pub const IN6ADDR_SOLICITEDNODEMULTICASTPREFIX_LENGTH = 104;
396pub const IN6ADDR_V4MAPPEDPREFIX_LENGTH = 96;
397pub const IN6ADDR_6TO4PREFIX_LENGTH = 16;
398pub const IN6ADDR_TEREDOPREFIX_LENGTH = 32;
399pub const MCAST_JOIN_GROUP = 41;
400pub const MCAST_LEAVE_GROUP = 42;
401pub const MCAST_BLOCK_SOURCE = 43;
402pub const MCAST_UNBLOCK_SOURCE = 44;
403pub const MCAST_JOIN_SOURCE_GROUP = 45;
404pub const MCAST_LEAVE_SOURCE_GROUP = 46;
405pub const IPV6_HOPOPTS = 1;
406pub const IPV6_HDRINCL = 2;
407pub const IPV6_UNICAST_HOPS = 4;
408pub const IPV6_MULTICAST_IF = 9;
409pub const IPV6_MULTICAST_HOPS = 10;
410pub const IPV6_MULTICAST_LOOP = 11;
411pub const IPV6_ADD_MEMBERSHIP = 12;
412pub const IPV6_DROP_MEMBERSHIP = 13;
413pub const IPV6_DONTFRAG = 14;
414pub const IPV6_PKTINFO = 19;
415pub const IPV6_HOPLIMIT = 21;
416pub const IPV6_PROTECTION_LEVEL = 23;
417pub const IPV6_RECVIF = 24;
418pub const IPV6_RECVDSTADDR = 25;
419pub const IPV6_CHECKSUM = 26;
420pub const IPV6_V6ONLY = 27;
421pub const IPV6_IFLIST = 28;
422pub const IPV6_ADD_IFLIST = 29;
423pub const IPV6_DEL_IFLIST = 30;
424pub const IPV6_UNICAST_IF = 31;
425pub const IPV6_RTHDR = 32;
426pub const IPV6_GET_IFLIST = 33;
427pub const IPV6_RECVRTHDR = 38;
428pub const IPV6_TCLASS = 39;
429pub const IPV6_RECVTCLASS = 40;
430pub const IPV6_ECN = 50;
431pub const IPV6_PKTINFO_EX = 51;
432pub const IPV6_WFP_REDIRECT_RECORDS = 60;
433pub const IPV6_WFP_REDIRECT_CONTEXT = 70;
434pub const IPV6_MTU_DISCOVER = 71;
435pub const IPV6_MTU = 72;
436pub const IPV6_NRT_INTERFACE = 74;
437pub const IPV6_RECVERR = 75;
438pub const IPV6_USER_MTU = 76;
439pub const IP_UNSPECIFIED_HOP_LIMIT = -1;
440pub const PROTECTION_LEVEL_UNRESTRICTED = 10;
441pub const PROTECTION_LEVEL_EDGERESTRICTED = 20;
442pub const PROTECTION_LEVEL_RESTRICTED = 30;
443pub const INET_ADDRSTRLEN = 22;
444pub const INET6_ADDRSTRLEN = 65;
445
446pub const TCP = struct {
447    pub const NODELAY = 1;
448    pub const EXPEDITED_1122 = 2;
449    pub const OFFLOAD_NO_PREFERENCE = 0;
450    pub const OFFLOAD_NOT_PREFERRED = 1;
451    pub const OFFLOAD_PREFERRED = 2;
452    pub const KEEPALIVE = 3;
453    pub const MAXSEG = 4;
454    pub const MAXRT = 5;
455    pub const STDURG = 6;
456    pub const NOURG = 7;
457    pub const ATMARK = 8;
458    pub const NOSYNRETRIES = 9;
459    pub const TIMESTAMPS = 10;
460    pub const OFFLOAD_PREFERENCE = 11;
461    pub const CONGESTION_ALGORITHM = 12;
462    pub const DELAY_FIN_ACK = 13;
463    pub const MAXRTMS = 14;
464    pub const FASTOPEN = 15;
465    pub const KEEPCNT = 16;
466    pub const KEEPINTVL = 17;
467    pub const FAIL_CONNECT_ON_ICMP_ERROR = 18;
468    pub const ICMP_ERROR_INFO = 19;
469    pub const BSDURGENT = 28672;
470};
471
472pub const UDP_SEND_MSG_SIZE = 2;
473pub const UDP_RECV_MAX_COALESCED_SIZE = 3;
474pub const UDP_COALESCED_INFO = 3;
475
476pub const AF = struct {
477    pub const UNSPEC = 0;
478    pub const UNIX = 1;
479    pub const INET = 2;
480    pub const IMPLINK = 3;
481    pub const PUP = 4;
482    pub const CHAOS = 5;
483    pub const NS = 6;
484    pub const IPX = 6;
485    pub const ISO = 7;
486    pub const ECMA = 8;
487    pub const DATAKIT = 9;
488    pub const CCITT = 10;
489    pub const SNA = 11;
490    pub const DECnet = 12;
491    pub const DLI = 13;
492    pub const LAT = 14;
493    pub const HYLINK = 15;
494    pub const APPLETALK = 16;
495    pub const NETBIOS = 17;
496    pub const VOICEVIEW = 18;
497    pub const FIREFOX = 19;
498    pub const UNKNOWN1 = 20;
499    pub const BAN = 21;
500    pub const ATM = 22;
501    pub const INET6 = 23;
502    pub const CLUSTER = 24;
503    pub const @"12844" = 25;
504    pub const IRDA = 26;
505    pub const NETDES = 28;
506    pub const MAX = 29;
507    pub const TCNPROCESS = 29;
508    pub const TCNMESSAGE = 30;
509    pub const ICLFXBM = 31;
510    pub const LINK = 33;
511    pub const HYPERV = 34;
512};
513
514pub const SOCK = struct {
515    pub const STREAM = 1;
516    pub const DGRAM = 2;
517    pub const RAW = 3;
518    pub const RDM = 4;
519    pub const SEQPACKET = 5;
520
521    /// WARNING: this flag is not supported by windows socket functions directly,
522    ///          it is only supported by std.os.socket. Be sure that this value does
523    ///          not share any bits with any of the `SOCK` values.
524    pub const CLOEXEC = 0x10000;
525    /// WARNING: this flag is not supported by windows socket functions directly,
526    ///          it is only supported by std.os.socket. Be sure that this value does
527    ///          not share any bits with any of the `SOCK` values.
528    pub const NONBLOCK = 0x20000;
529};
530
531pub const SOL = struct {
532    pub const IRLMP = 255;
533    pub const SOCKET = 65535;
534};
535
536pub const SO = struct {
537    pub const DEBUG = 1;
538    pub const ACCEPTCONN = 2;
539    pub const REUSEADDR = 4;
540    pub const KEEPALIVE = 8;
541    pub const DONTROUTE = 16;
542    pub const BROADCAST = 32;
543    pub const USELOOPBACK = 64;
544    pub const LINGER = 128;
545    pub const OOBINLINE = 256;
546    pub const SNDBUF = 4097;
547    pub const RCVBUF = 4098;
548    pub const SNDLOWAT = 4099;
549    pub const RCVLOWAT = 4100;
550    pub const SNDTIMEO = 4101;
551    pub const RCVTIMEO = 4102;
552    pub const ERROR = 4103;
553    pub const TYPE = 4104;
554    pub const BSP_STATE = 4105;
555    pub const GROUP_ID = 8193;
556    pub const GROUP_PRIORITY = 8194;
557    pub const MAX_MSG_SIZE = 8195;
558    pub const CONDITIONAL_ACCEPT = 12290;
559    pub const PAUSE_ACCEPT = 12291;
560    pub const COMPARTMENT_ID = 12292;
561    pub const RANDOMIZE_PORT = 12293;
562    pub const PORT_SCALABILITY = 12294;
563    pub const REUSE_UNICASTPORT = 12295;
564    pub const REUSE_MULTICASTPORT = 12296;
565    pub const ORIGINAL_DST = 12303;
566    pub const PROTOCOL_INFOA = 8196;
567    pub const PROTOCOL_INFOW = 8197;
568    pub const CONNDATA = 28672;
569    pub const CONNOPT = 28673;
570    pub const DISCDATA = 28674;
571    pub const DISCOPT = 28675;
572    pub const CONNDATALEN = 28676;
573    pub const CONNOPTLEN = 28677;
574    pub const DISCDATALEN = 28678;
575    pub const DISCOPTLEN = 28679;
576    pub const OPENTYPE = 28680;
577    pub const SYNCHRONOUS_ALERT = 16;
578    pub const SYNCHRONOUS_NONALERT = 32;
579    pub const MAXDG = 28681;
580    pub const MAXPATHDG = 28682;
581    pub const UPDATE_ACCEPT_CONTEXT = 28683;
582    pub const CONNECT_TIME = 28684;
583    pub const UPDATE_CONNECT_CONTEXT = 28688;
584};
585
586pub const WSK_SO_BASE = 16384;
587pub const IOC_UNIX = 0;
588pub const IOC_WS2 = 134217728;
589pub const IOC_PROTOCOL = 268435456;
590pub const IOC_VENDOR = 402653184;
591pub const SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_OUT | IOC_IN | IOC_WS2 | 6;
592pub const SIO_BSP_HANDLE = IOC_OUT | IOC_WS2 | 27;
593pub const SIO_BSP_HANDLE_SELECT = IOC_OUT | IOC_WS2 | 28;
594pub const SIO_BSP_HANDLE_POLL = IOC_OUT | IOC_WS2 | 29;
595pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;
596pub const IPPORT_TCPMUX = 1;
597pub const IPPORT_ECHO = 7;
598pub const IPPORT_DISCARD = 9;
599pub const IPPORT_SYSTAT = 11;
600pub const IPPORT_DAYTIME = 13;
601pub const IPPORT_NETSTAT = 15;
602pub const IPPORT_QOTD = 17;
603pub const IPPORT_MSP = 18;
604pub const IPPORT_CHARGEN = 19;
605pub const IPPORT_FTP_DATA = 20;
606pub const IPPORT_FTP = 21;
607pub const IPPORT_TELNET = 23;
608pub const IPPORT_SMTP = 25;
609pub const IPPORT_TIMESERVER = 37;
610pub const IPPORT_NAMESERVER = 42;
611pub const IPPORT_WHOIS = 43;
612pub const IPPORT_MTP = 57;
613pub const IPPORT_TFTP = 69;
614pub const IPPORT_RJE = 77;
615pub const IPPORT_FINGER = 79;
616pub const IPPORT_TTYLINK = 87;
617pub const IPPORT_SUPDUP = 95;
618pub const IPPORT_POP3 = 110;
619pub const IPPORT_NTP = 123;
620pub const IPPORT_EPMAP = 135;
621pub const IPPORT_NETBIOS_NS = 137;
622pub const IPPORT_NETBIOS_DGM = 138;
623pub const IPPORT_NETBIOS_SSN = 139;
624pub const IPPORT_IMAP = 143;
625pub const IPPORT_SNMP = 161;
626pub const IPPORT_SNMP_TRAP = 162;
627pub const IPPORT_IMAP3 = 220;
628pub const IPPORT_LDAP = 389;
629pub const IPPORT_HTTPS = 443;
630pub const IPPORT_MICROSOFT_DS = 445;
631pub const IPPORT_EXECSERVER = 512;
632pub const IPPORT_LOGINSERVER = 513;
633pub const IPPORT_CMDSERVER = 514;
634pub const IPPORT_EFSSERVER = 520;
635pub const IPPORT_BIFFUDP = 512;
636pub const IPPORT_WHOSERVER = 513;
637pub const IPPORT_ROUTESERVER = 520;
638pub const IPPORT_RESERVED = 1024;
639pub const IPPORT_REGISTERED_MAX = 49151;
640pub const IPPORT_DYNAMIC_MIN = 49152;
641pub const IPPORT_DYNAMIC_MAX = 65535;
642pub const IN_CLASSA_NET = 4278190080;
643pub const IN_CLASSA_NSHIFT = 24;
644pub const IN_CLASSA_HOST = 16777215;
645pub const IN_CLASSA_MAX = 128;
646pub const IN_CLASSB_NET = 4294901760;
647pub const IN_CLASSB_NSHIFT = 16;
648pub const IN_CLASSB_HOST = 65535;
649pub const IN_CLASSB_MAX = 65536;
650pub const IN_CLASSC_NET = 4294967040;
651pub const IN_CLASSC_NSHIFT = 8;
652pub const IN_CLASSC_HOST = 255;
653pub const IN_CLASSD_NET = 4026531840;
654pub const IN_CLASSD_NSHIFT = 28;
655pub const IN_CLASSD_HOST = 268435455;
656pub const INADDR_LOOPBACK = 2130706433;
657pub const INADDR_NONE = 4294967295;
658pub const IOCPARM_MASK = 127;
659pub const IOC_VOID = 536870912;
660pub const IOC_OUT = 1073741824;
661pub const IOC_IN = 2147483648;
662
663pub const MSG = struct {
664    pub const TRUNC = 256;
665    pub const CTRUNC = 512;
666    pub const BCAST = 1024;
667    pub const MCAST = 2048;
668    pub const ERRQUEUE = 4096;
669
670    pub const PEEK = 2;
671    pub const WAITALL = 8;
672    pub const PUSH_IMMEDIATE = 32;
673    pub const PARTIAL = 32768;
674    pub const INTERRUPT = 16;
675    pub const MAXIOVLEN = 16;
676};
677
678pub const AI = struct {
679    pub const PASSIVE = 1;
680    pub const CANONNAME = 2;
681    pub const NUMERICHOST = 4;
682    pub const NUMERICSERV = 8;
683    pub const DNS_ONLY = 16;
684    pub const ALL = 256;
685    pub const ADDRCONFIG = 1024;
686    pub const V4MAPPED = 2048;
687    pub const NON_AUTHORITATIVE = 16384;
688    pub const SECURE = 32768;
689    pub const RETURN_PREFERRED_NAMES = 65536;
690    pub const FQDN = 131072;
691    pub const FILESERVER = 262144;
692    pub const DISABLE_IDN_ENCODING = 524288;
693    pub const EXTENDED = 2147483648;
694    pub const RESOLUTION_HANDLE = 1073741824;
695};
696
697pub const FIONBIO = -2147195266;
698pub const ADDRINFOEX_VERSION_2 = 2;
699pub const ADDRINFOEX_VERSION_3 = 3;
700pub const ADDRINFOEX_VERSION_4 = 4;
701pub const NS_ALL = 0;
702pub const NS_SAP = 1;
703pub const NS_NDS = 2;
704pub const NS_PEER_BROWSE = 3;
705pub const NS_SLP = 5;
706pub const NS_DHCP = 6;
707pub const NS_TCPIP_LOCAL = 10;
708pub const NS_TCPIP_HOSTS = 11;
709pub const NS_DNS = 12;
710pub const NS_NETBT = 13;
711pub const NS_WINS = 14;
712pub const NS_NLA = 15;
713pub const NS_NBP = 20;
714pub const NS_MS = 30;
715pub const NS_STDA = 31;
716pub const NS_NTDS = 32;
717pub const NS_EMAIL = 37;
718pub const NS_X500 = 40;
719pub const NS_NIS = 41;
720pub const NS_NISPLUS = 42;
721pub const NS_WRQ = 50;
722pub const NS_NETDES = 60;
723pub const NI_NOFQDN = 1;
724pub const NI_NUMERICHOST = 2;
725pub const NI_NAMEREQD = 4;
726pub const NI_NUMERICSERV = 8;
727pub const NI_DGRAM = 16;
728pub const NI_MAXHOST = 1025;
729pub const NI_MAXSERV = 32;
730pub const INCL_WINSOCK_API_PROTOTYPES = 1;
731pub const INCL_WINSOCK_API_TYPEDEFS = 0;
732pub const FD_SETSIZE = 64;
733pub const IMPLINK_IP = 155;
734pub const IMPLINK_LOWEXPER = 156;
735pub const IMPLINK_HIGHEXPER = 158;
736pub const WSADESCRIPTION_LEN = 256;
737pub const WSASYS_STATUS_LEN = 128;
738pub const SOCKET_ERROR = -1;
739pub const FROM_PROTOCOL_INFO = -1;
740pub const PVD_CONFIG = 12289;
741pub const SOMAXCONN = 2147483647;
742pub const MAXGETHOSTSTRUCT = 1024;
743pub const FD_READ_BIT = 0;
744pub const FD_WRITE_BIT = 1;
745pub const FD_OOB_BIT = 2;
746pub const FD_ACCEPT_BIT = 3;
747pub const FD_CONNECT_BIT = 4;
748pub const FD_CLOSE_BIT = 5;
749pub const FD_QOS_BIT = 6;
750pub const FD_GROUP_QOS_BIT = 7;
751pub const FD_ROUTING_INTERFACE_CHANGE_BIT = 8;
752pub const FD_ADDRESS_LIST_CHANGE_BIT = 9;
753pub const FD_MAX_EVENTS = 10;
754pub const CF_ACCEPT = 0;
755pub const CF_REJECT = 1;
756pub const CF_DEFER = 2;
757pub const SD_RECEIVE = 0;
758pub const SD_SEND = 1;
759pub const SD_BOTH = 2;
760pub const SG_UNCONSTRAINED_GROUP = 1;
761pub const SG_CONSTRAINED_GROUP = 2;
762pub const MAX_PROTOCOL_CHAIN = 7;
763pub const BASE_PROTOCOL = 1;
764pub const LAYERED_PROTOCOL = 0;
765pub const WSAPROTOCOL_LEN = 255;
766pub const PFL_MULTIPLE_PROTO_ENTRIES = 1;
767pub const PFL_RECOMMENDED_PROTO_ENTRY = 2;
768pub const PFL_HIDDEN = 4;
769pub const PFL_MATCHES_PROTOCOL_ZERO = 8;
770pub const PFL_NETWORKDIRECT_PROVIDER = 16;
771pub const XP1_CONNECTIONLESS = 1;
772pub const XP1_GUARANTEED_DELIVERY = 2;
773pub const XP1_GUARANTEED_ORDER = 4;
774pub const XP1_MESSAGE_ORIENTED = 8;
775pub const XP1_PSEUDO_STREAM = 16;
776pub const XP1_GRACEFUL_CLOSE = 32;
777pub const XP1_EXPEDITED_DATA = 64;
778pub const XP1_CONNECT_DATA = 128;
779pub const XP1_DISCONNECT_DATA = 256;
780pub const XP1_SUPPORT_BROADCAST = 512;
781pub const XP1_SUPPORT_MULTIPOINT = 1024;
782pub const XP1_MULTIPOINT_CONTROL_PLANE = 2048;
783pub const XP1_MULTIPOINT_DATA_PLANE = 4096;
784pub const XP1_QOS_SUPPORTED = 8192;
785pub const XP1_INTERRUPT = 16384;
786pub const XP1_UNI_SEND = 32768;
787pub const XP1_UNI_RECV = 65536;
788pub const XP1_IFS_HANDLES = 131072;
789pub const XP1_PARTIAL_MESSAGE = 262144;
790pub const XP1_SAN_SUPPORT_SDP = 524288;
791pub const BIGENDIAN = 0;
792pub const LITTLEENDIAN = 1;
793pub const SECURITY_PROTOCOL_NONE = 0;
794pub const JL_SENDER_ONLY = 1;
795pub const JL_RECEIVER_ONLY = 2;
796pub const JL_BOTH = 4;
797pub const WSA_FLAG_OVERLAPPED = 1;
798pub const WSA_FLAG_MULTIPOINT_C_ROOT = 2;
799pub const WSA_FLAG_MULTIPOINT_C_LEAF = 4;
800pub const WSA_FLAG_MULTIPOINT_D_ROOT = 8;
801pub const WSA_FLAG_MULTIPOINT_D_LEAF = 16;
802pub const WSA_FLAG_ACCESS_SYSTEM_SECURITY = 64;
803pub const WSA_FLAG_NO_HANDLE_INHERIT = 128;
804pub const WSA_FLAG_REGISTERED_IO = 256;
805pub const TH_NETDEV = 1;
806pub const TH_TAPI = 2;
807pub const SERVICE_MULTIPLE = 1;
808pub const NS_LOCALNAME = 19;
809pub const RES_UNUSED_1 = 1;
810pub const RES_FLUSH_CACHE = 2;
811pub const RES_SERVICE = 4;
812pub const LUP_DEEP = 1;
813pub const LUP_CONTAINERS = 2;
814pub const LUP_NOCONTAINERS = 4;
815pub const LUP_NEAREST = 8;
816pub const LUP_RETURN_NAME = 16;
817pub const LUP_RETURN_TYPE = 32;
818pub const LUP_RETURN_VERSION = 64;
819pub const LUP_RETURN_COMMENT = 128;
820pub const LUP_RETURN_ADDR = 256;
821pub const LUP_RETURN_BLOB = 512;
822pub const LUP_RETURN_ALIASES = 1024;
823pub const LUP_RETURN_QUERY_STRING = 2048;
824pub const LUP_RETURN_ALL = 4080;
825pub const LUP_RES_SERVICE = 32768;
826pub const LUP_FLUSHCACHE = 4096;
827pub const LUP_FLUSHPREVIOUS = 8192;
828pub const LUP_NON_AUTHORITATIVE = 16384;
829pub const LUP_SECURE = 32768;
830pub const LUP_RETURN_PREFERRED_NAMES = 65536;
831pub const LUP_DNS_ONLY = 131072;
832pub const LUP_ADDRCONFIG = 1048576;
833pub const LUP_DUAL_ADDR = 2097152;
834pub const LUP_FILESERVER = 4194304;
835pub const LUP_DISABLE_IDN_ENCODING = 8388608;
836pub const LUP_API_ANSI = 16777216;
837pub const LUP_RESOLUTION_HANDLE = 2147483648;
838pub const RESULT_IS_ALIAS = 1;
839pub const RESULT_IS_ADDED = 16;
840pub const RESULT_IS_CHANGED = 32;
841pub const RESULT_IS_DELETED = 64;
842
843pub const POLL = struct {
844    pub const RDNORM = 256;
845    pub const RDBAND = 512;
846    pub const PRI = 1024;
847    pub const WRNORM = 16;
848    pub const WRBAND = 32;
849    pub const ERR = 1;
850    pub const HUP = 2;
851    pub const NVAL = 4;
852};
853
854pub const TF_DISCONNECT = 1;
855pub const TF_REUSE_SOCKET = 2;
856pub const TF_WRITE_BEHIND = 4;
857pub const TF_USE_DEFAULT_WORKER = 0;
858pub const TF_USE_SYSTEM_THREAD = 16;
859pub const TF_USE_KERNEL_APC = 32;
860pub const TP_ELEMENT_MEMORY = 1;
861pub const TP_ELEMENT_FILE = 2;
862pub const TP_ELEMENT_EOP = 4;
863pub const NLA_ALLUSERS_NETWORK = 1;
864pub const NLA_FRIENDLY_NAME = 2;
865pub const WSPDESCRIPTION_LEN = 255;
866pub const WSS_OPERATION_IN_PROGRESS = 259;
867pub const LSP_SYSTEM = 2147483648;
868pub const LSP_INSPECTOR = 1;
869pub const LSP_REDIRECTOR = 2;
870pub const LSP_PROXY = 4;
871pub const LSP_FIREWALL = 8;
872pub const LSP_INBOUND_MODIFY = 16;
873pub const LSP_OUTBOUND_MODIFY = 32;
874pub const LSP_CRYPTO_COMPRESS = 64;
875pub const LSP_LOCAL_CACHE = 128;
876
877pub const IPPROTO = struct {
878    pub const IP = 0;
879    pub const ICMP = 1;
880    pub const IGMP = 2;
881    pub const GGP = 3;
882    pub const TCP = 6;
883    pub const PUP = 12;
884    pub const UDP = 17;
885    pub const IDP = 22;
886    pub const ND = 77;
887    pub const RM = 113;
888    pub const RAW = 255;
889    pub const MAX = 256;
890};
891
892pub const IP_DEFAULT_MULTICAST_TTL = 1;
893pub const IP_DEFAULT_MULTICAST_LOOP = 1;
894pub const IP_MAX_MEMBERSHIPS = 20;
895pub const FD_READ = 1;
896pub const FD_WRITE = 2;
897pub const FD_OOB = 4;
898pub const FD_ACCEPT = 8;
899pub const FD_CONNECT = 16;
900pub const FD_CLOSE = 32;
901pub const SERVICE_RESOURCE = 1;
902pub const SERVICE_SERVICE = 2;
903pub const SERVICE_LOCAL = 4;
904pub const SERVICE_FLAG_DEFER = 1;
905pub const SERVICE_FLAG_HARD = 2;
906pub const PROP_COMMENT = 1;
907pub const PROP_LOCALE = 2;
908pub const PROP_DISPLAY_HINT = 4;
909pub const PROP_VERSION = 8;
910pub const PROP_START_TIME = 16;
911pub const PROP_MACHINE = 32;
912pub const PROP_ADDRESSES = 256;
913pub const PROP_SD = 512;
914pub const PROP_ALL = 2147483648;
915pub const SERVICE_ADDRESS_FLAG_RPC_CN = 1;
916pub const SERVICE_ADDRESS_FLAG_RPC_DG = 2;
917pub const SERVICE_ADDRESS_FLAG_RPC_NB = 4;
918pub const NS_DEFAULT = 0;
919pub const NS_VNS = 50;
920pub const NSTYPE_HIERARCHICAL = 1;
921pub const NSTYPE_DYNAMIC = 2;
922pub const NSTYPE_ENUMERABLE = 4;
923pub const NSTYPE_WORKGROUP = 8;
924pub const XP_CONNECTIONLESS = 1;
925pub const XP_GUARANTEED_DELIVERY = 2;
926pub const XP_GUARANTEED_ORDER = 4;
927pub const XP_MESSAGE_ORIENTED = 8;
928pub const XP_PSEUDO_STREAM = 16;
929pub const XP_GRACEFUL_CLOSE = 32;
930pub const XP_EXPEDITED_DATA = 64;
931pub const XP_CONNECT_DATA = 128;
932pub const XP_DISCONNECT_DATA = 256;
933pub const XP_SUPPORTS_BROADCAST = 512;
934pub const XP_SUPPORTS_MULTICAST = 1024;
935pub const XP_BANDWIDTH_ALLOCATION = 2048;
936pub const XP_FRAGMENTATION = 4096;
937pub const XP_ENCRYPTS = 8192;
938pub const RES_SOFT_SEARCH = 1;
939pub const RES_FIND_MULTIPLE = 2;
940pub const SET_SERVICE_PARTIAL_SUCCESS = 1;
941pub const UDP_NOCHECKSUM = 1;
942pub const UDP_CHECKSUM_COVERAGE = 20;
943pub const GAI_STRERROR_BUFFER_SIZE = 1024;
944
945pub const LPCONDITIONPROC = fn (
946    lpCallerId: *WSABUF,
947    lpCallerData: *WSABUF,
948    lpSQOS: *QOS,
949    lpGQOS: *QOS,
950    lpCalleeId: *WSABUF,
951    lpCalleeData: *WSABUF,
952    g: *u32,
953    dwCallbackData: usize,
954) callconv(WINAPI) i32;
955
956pub const LPWSAOVERLAPPED_COMPLETION_ROUTINE = fn (
957    dwError: u32,
958    cbTransferred: u32,
959    lpOverlapped: *OVERLAPPED,
960    dwFlags: u32,
961) callconv(WINAPI) void;
962
963pub const FLOWSPEC = extern struct {
964    TokenRate: u32,
965    TokenBucketSize: u32,
966    PeakBandwidth: u32,
967    Latency: u32,
968    DelayVariation: u32,
969    ServiceType: u32,
970    MaxSduSize: u32,
971    MinimumPolicedSize: u32,
972};
973
974pub const QOS = extern struct {
975    SendingFlowspec: FLOWSPEC,
976    ReceivingFlowspec: FLOWSPEC,
977    ProviderSpecific: WSABUF,
978};
979
980pub const SOCKET_ADDRESS = extern struct {
981    lpSockaddr: *sockaddr,
982    iSockaddrLength: i32,
983};
984
985pub const SOCKET_ADDRESS_LIST = extern struct {
986    iAddressCount: i32,
987    Address: [1]SOCKET_ADDRESS,
988};
989
990pub const WSADATA = if (@sizeOf(usize) == @sizeOf(u64))
991    extern struct {
992        wVersion: WORD,
993        wHighVersion: WORD,
994        iMaxSockets: u16,
995        iMaxUdpDg: u16,
996        lpVendorInfo: *u8,
997        szDescription: [WSADESCRIPTION_LEN + 1]u8,
998        szSystemStatus: [WSASYS_STATUS_LEN + 1]u8,
999    }
1000else
1001    extern struct {
1002        wVersion: WORD,
1003        wHighVersion: WORD,
1004        szDescription: [WSADESCRIPTION_LEN + 1]u8,
1005        szSystemStatus: [WSASYS_STATUS_LEN + 1]u8,
1006        iMaxSockets: u16,
1007        iMaxUdpDg: u16,
1008        lpVendorInfo: *u8,
1009    };
1010
1011pub const WSAPROTOCOLCHAIN = extern struct {
1012    ChainLen: c_int,
1013    ChainEntries: [MAX_PROTOCOL_CHAIN]DWORD,
1014};
1015
1016pub const WSAPROTOCOL_INFOA = extern struct {
1017    dwServiceFlags1: DWORD,
1018    dwServiceFlags2: DWORD,
1019    dwServiceFlags3: DWORD,
1020    dwServiceFlags4: DWORD,
1021    dwProviderFlags: DWORD,
1022    ProviderId: GUID,
1023    dwCatalogEntryId: DWORD,
1024    ProtocolChain: WSAPROTOCOLCHAIN,
1025    iVersion: c_int,
1026    iAddressFamily: c_int,
1027    iMaxSockAddr: c_int,
1028    iMinSockAddr: c_int,
1029    iSocketType: c_int,
1030    iProtocol: c_int,
1031    iProtocolMaxOffset: c_int,
1032    iNetworkByteOrder: c_int,
1033    iSecurityScheme: c_int,
1034    dwMessageSize: DWORD,
1035    dwProviderReserved: DWORD,
1036    szProtocol: [WSAPROTOCOL_LEN + 1]CHAR,
1037};
1038
1039pub const WSAPROTOCOL_INFOW = extern struct {
1040    dwServiceFlags1: DWORD,
1041    dwServiceFlags2: DWORD,
1042    dwServiceFlags3: DWORD,
1043    dwServiceFlags4: DWORD,
1044    dwProviderFlags: DWORD,
1045    ProviderId: GUID,
1046    dwCatalogEntryId: DWORD,
1047    ProtocolChain: WSAPROTOCOLCHAIN,
1048    iVersion: c_int,
1049    iAddressFamily: c_int,
1050    iMaxSockAddr: c_int,
1051    iMinSockAddr: c_int,
1052    iSocketType: c_int,
1053    iProtocol: c_int,
1054    iProtocolMaxOffset: c_int,
1055    iNetworkByteOrder: c_int,
1056    iSecurityScheme: c_int,
1057    dwMessageSize: DWORD,
1058    dwProviderReserved: DWORD,
1059    szProtocol: [WSAPROTOCOL_LEN + 1]WCHAR,
1060};
1061
1062pub const sockproto = extern struct {
1063    sp_family: u16,
1064    sp_protocol: u16,
1065};
1066
1067pub const linger = extern struct {
1068    l_onoff: u16,
1069    l_linger: u16,
1070};
1071
1072pub const WSANETWORKEVENTS = extern struct {
1073    lNetworkEvents: i32,
1074    iErrorCode: [10]i32,
1075};
1076
1077pub const addrinfo = addrinfoa;
1078
1079pub const addrinfoa = extern struct {
1080    flags: i32,
1081    family: i32,
1082    socktype: i32,
1083    protocol: i32,
1084    addrlen: usize,
1085    canonname: ?[*:0]u8,
1086    addr: ?*sockaddr,
1087    next: ?*addrinfo,
1088};
1089
1090pub const addrinfoexA = extern struct {
1091    ai_flags: i32,
1092    ai_family: i32,
1093    ai_socktype: i32,
1094    ai_protocol: i32,
1095    ai_addrlen: usize,
1096    ai_canonname: [*:0]u8,
1097    ai_addr: *sockaddr,
1098    ai_blob: *anyopaque,
1099    ai_bloblen: usize,
1100    ai_provider: *GUID,
1101    ai_next: *addrinfoexA,
1102};
1103
1104pub const sockaddr = extern struct {
1105    family: ADDRESS_FAMILY,
1106    data: [14]u8,
1107
1108    pub const SS_MAXSIZE = 128;
1109    pub const storage = std.x.os.Socket.Address.Native.Storage;
1110
1111    /// IPv4 socket address
1112    pub const in = extern struct {
1113        family: ADDRESS_FAMILY = AF.INET,
1114        port: USHORT,
1115        addr: u32,
1116        zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
1117    };
1118
1119    /// IPv6 socket address
1120    pub const in6 = extern struct {
1121        family: ADDRESS_FAMILY = AF.INET6,
1122        port: USHORT,
1123        flowinfo: u32,
1124        addr: [16]u8,
1125        scope_id: u32,
1126    };
1127
1128    /// UNIX domain socket address
1129    pub const un = extern struct {
1130        family: ADDRESS_FAMILY = AF.UNIX,
1131        path: [108]u8,
1132    };
1133};
1134
1135pub const WSABUF = extern struct {
1136    len: ULONG,
1137    buf: [*]u8,
1138};
1139
1140pub const msghdr = WSAMSG;
1141pub const msghdr_const = WSAMSG_const;
1142
1143pub const WSAMSG_const = extern struct {
1144    name: *const sockaddr,
1145    namelen: INT,
1146    lpBuffers: [*]WSABUF,
1147    dwBufferCount: DWORD,
1148    Control: WSABUF,
1149    dwFlags: DWORD,
1150};
1151
1152pub const WSAMSG = extern struct {
1153    name: *sockaddr,
1154    namelen: INT,
1155    lpBuffers: [*]WSABUF,
1156    dwBufferCount: DWORD,
1157    Control: WSABUF,
1158    dwFlags: DWORD,
1159};
1160
1161pub const WSAPOLLFD = pollfd;
1162
1163pub const pollfd = extern struct {
1164    fd: SOCKET,
1165    events: SHORT,
1166    revents: SHORT,
1167};
1168
1169pub const TRANSMIT_FILE_BUFFERS = extern struct {
1170    Head: *anyopaque,
1171    HeadLength: u32,
1172    Tail: *anyopaque,
1173    TailLength: u32,
1174};
1175
1176pub const LPFN_TRANSMITFILE = fn (
1177    hSocket: SOCKET,
1178    hFile: HANDLE,
1179    nNumberOfBytesToWrite: u32,
1180    nNumberOfBytesPerSend: u32,
1181    lpOverlapped: ?*OVERLAPPED,
1182    lpTransmitBuffers: ?*TRANSMIT_FILE_BUFFERS,
1183    dwReserved: u32,
1184) callconv(WINAPI) BOOL;
1185
1186pub const LPFN_ACCEPTEX = fn (
1187    sListenSocket: SOCKET,
1188    sAcceptSocket: SOCKET,
1189    lpOutputBuffer: *anyopaque,
1190    dwReceiveDataLength: u32,
1191    dwLocalAddressLength: u32,
1192    dwRemoteAddressLength: u32,
1193    lpdwBytesReceived: *u32,
1194    lpOverlapped: *OVERLAPPED,
1195) callconv(WINAPI) BOOL;
1196
1197pub const LPFN_GETACCEPTEXSOCKADDRS = fn (
1198    lpOutputBuffer: *anyopaque,
1199    dwReceiveDataLength: u32,
1200    dwLocalAddressLength: u32,
1201    dwRemoteAddressLength: u32,
1202    LocalSockaddr: **sockaddr,
1203    LocalSockaddrLength: *i32,
1204    RemoteSockaddr: **sockaddr,
1205    RemoteSockaddrLength: *i32,
1206) callconv(WINAPI) void;
1207
1208pub const LPFN_WSASENDMSG = fn (
1209    s: SOCKET,
1210    lpMsg: *const std.x.os.Socket.Message,
1211    dwFlags: u32,
1212    lpNumberOfBytesSent: ?*u32,
1213    lpOverlapped: ?*OVERLAPPED,
1214    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
1215) callconv(WINAPI) i32;
1216
1217pub const LPFN_WSARECVMSG = fn (
1218    s: SOCKET,
1219    lpMsg: *std.x.os.Socket.Message,
1220    lpdwNumberOfBytesRecv: ?*u32,
1221    lpOverlapped: ?*OVERLAPPED,
1222    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
1223) callconv(WINAPI) i32;
1224
1225pub const LPSERVICE_CALLBACK_PROC = fn (
1226    lParam: LPARAM,
1227    hAsyncTaskHandle: HANDLE,
1228) callconv(WINAPI) void;
1229
1230pub const SERVICE_ASYNC_INFO = extern struct {
1231    lpServiceCallbackProc: LPSERVICE_CALLBACK_PROC,
1232    lParam: LPARAM,
1233    hAsyncTaskHandle: HANDLE,
1234};
1235
1236pub const LPLOOKUPSERVICE_COMPLETION_ROUTINE = fn (
1237    dwError: u32,
1238    dwBytes: u32,
1239    lpOverlapped: *OVERLAPPED,
1240) callconv(WINAPI) void;
1241
1242pub const fd_set = extern struct {
1243    fd_count: u32,
1244    fd_array: [64]SOCKET,
1245};
1246
1247pub const hostent = extern struct {
1248    h_name: [*]u8,
1249    h_aliases: **i8,
1250    h_addrtype: i16,
1251    h_length: i16,
1252    h_addr_list: **i8,
1253};
1254
1255// https://docs.microsoft.com/en-au/windows/win32/winsock/windows-sockets-error-codes-2
1256pub const WinsockError = enum(u16) {
1257    /// Specified event object handle is invalid.
1258    /// An application attempts to use an event object, but the specified handle is not valid.
1259    WSA_INVALID_HANDLE = 6,
1260
1261    /// Insufficient memory available.
1262    /// An application used a Windows Sockets function that directly maps to a Windows function.
1263    /// The Windows function is indicating a lack of required memory resources.
1264    WSA_NOT_ENOUGH_MEMORY = 8,
1265
1266    /// One or more parameters are invalid.
1267    /// An application used a Windows Sockets function which directly maps to a Windows function.
1268    /// The Windows function is indicating a problem with one or more parameters.
1269    WSA_INVALID_PARAMETER = 87,
1270
1271    /// Overlapped operation aborted.
1272    /// An overlapped operation was canceled due to the closure of the socket, or the execution of the SIO_FLUSH command in WSAIoctl.
1273    WSA_OPERATION_ABORTED = 995,
1274
1275    /// Overlapped I/O event object not in signaled state.
1276    /// The application has tried to determine the status of an overlapped operation which is not yet completed.
1277    /// Applications that use WSAGetOverlappedResult (with the fWait flag set to FALSE) in a polling mode to determine when an overlapped operation has completed, get this error code until the operation is complete.
1278    WSA_IO_INCOMPLETE = 996,
1279
1280    /// The application has initiated an overlapped operation that cannot be completed immediately.
1281    /// A completion indication will be given later when the operation has been completed.
1282    WSA_IO_PENDING = 997,
1283
1284    /// Interrupted function call.
1285    /// A blocking operation was interrupted by a call to WSACancelBlockingCall.
1286    WSAEINTR = 10004,
1287
1288    /// File handle is not valid.
1289    /// The file handle supplied is not valid.
1290    WSAEBADF = 10009,
1291
1292    /// Permission denied.
1293    /// An attempt was made to access a socket in a way forbidden by its access permissions.
1294    /// An example is using a broadcast address for sendto without broadcast permission being set using setsockopt(SO.BROADCAST).
1295    /// Another possible reason for the WSAEACCES error is that when the bind function is called (on Windows NT 4.0 with SP4 and later), another application, service, or kernel mode driver is bound to the same address with exclusive access.
1296    /// Such exclusive access is a new feature of Windows NT 4.0 with SP4 and later, and is implemented by using the SO.EXCLUSIVEADDRUSE option.
1297    WSAEACCES = 10013,
1298
1299    /// Bad address.
1300    /// The system detected an invalid pointer address in attempting to use a pointer argument of a call.
1301    /// This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small.
1302    /// For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr).
1303    WSAEFAULT = 10014,
1304
1305    /// Invalid argument.
1306    /// Some invalid argument was supplied (for example, specifying an invalid level to the setsockopt function).
1307    /// In some instances, it also refers to the current state of the socket—for instance, calling accept on a socket that is not listening.
1308    WSAEINVAL = 10022,
1309
1310    /// Too many open files.
1311    /// Too many open sockets. Each implementation may have a maximum number of socket handles available, either globally, per process, or per thread.
1312    WSAEMFILE = 10024,
1313
1314    /// Resource temporarily unavailable.
1315    /// This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket.
1316    /// It is a nonfatal error, and the operation should be retried later.
1317    /// It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK.STREAM socket, since some time must elapse for the connection to be established.
1318    WSAEWOULDBLOCK = 10035,
1319
1320    /// Operation now in progress.
1321    /// A blocking operation is currently executing.
1322    /// Windows Sockets only allows a single blocking operation—per- task or thread—to be outstanding, and if any other function call is made (whether or not it references that or any other socket) the function fails with the WSAEINPROGRESS error.
1323    WSAEINPROGRESS = 10036,
1324
1325    /// Operation already in progress.
1326    /// An operation was attempted on a nonblocking socket with an operation already in progress—that is, calling connect a second time on a nonblocking socket that is already connecting, or canceling an asynchronous request (WSAAsyncGetXbyY) that has already been canceled or completed.
1327    WSAEALREADY = 10037,
1328
1329    /// Socket operation on nonsocket.
1330    /// An operation was attempted on something that is not a socket.
1331    /// Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.
1332    WSAENOTSOCK = 10038,
1333
1334    /// Destination address required.
1335    /// A required address was omitted from an operation on a socket.
1336    /// For example, this error is returned if sendto is called with the remote address of ADDR_ANY.
1337    WSAEDESTADDRREQ = 10039,
1338
1339    /// Message too long.
1340    /// A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram was smaller than the datagram itself.
1341    WSAEMSGSIZE = 10040,
1342
1343    /// Protocol wrong type for socket.
1344    /// A protocol was specified in the socket function call that does not support the semantics of the socket type requested.
1345    /// For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK.STREAM.
1346    WSAEPROTOTYPE = 10041,
1347
1348    /// Bad protocol option.
1349    /// An unknown, invalid or unsupported option or level was specified in a getsockopt or setsockopt call.
1350    WSAENOPROTOOPT = 10042,
1351
1352    /// Protocol not supported.
1353    /// The requested protocol has not been configured into the system, or no implementation for it exists.
1354    /// For example, a socket call requests a SOCK.DGRAM socket, but specifies a stream protocol.
1355    WSAEPROTONOSUPPORT = 10043,
1356
1357    /// Socket type not supported.
1358    /// The support for the specified socket type does not exist in this address family.
1359    /// For example, the optional type SOCK.RAW might be selected in a socket call, and the implementation does not support SOCK.RAW sockets at all.
1360    WSAESOCKTNOSUPPORT = 10044,
1361
1362    /// Operation not supported.
1363    /// The attempted operation is not supported for the type of object referenced.
1364    /// Usually this occurs when a socket descriptor to a socket that cannot support this operation is trying to accept a connection on a datagram socket.
1365    WSAEOPNOTSUPP = 10045,
1366
1367    /// Protocol family not supported.
1368    /// The protocol family has not been configured into the system or no implementation for it exists.
1369    /// This message has a slightly different meaning from WSAEAFNOSUPPORT.
1370    /// However, it is interchangeable in most cases, and all Windows Sockets functions that return one of these messages also specify WSAEAFNOSUPPORT.
1371    WSAEPFNOSUPPORT = 10046,
1372
1373    /// Address family not supported by protocol family.
1374    /// An address incompatible with the requested protocol was used.
1375    /// All sockets are created with an associated address family (that is, AF.INET for Internet Protocols) and a generic protocol type (that is, SOCK.STREAM).
1376    /// This error is returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, for example, in sendto.
1377    WSAEAFNOSUPPORT = 10047,
1378
1379    /// Address already in use.
1380    /// Typically, only one usage of each socket address (protocol/IP address/port) is permitted.
1381    /// This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that was not closed properly, or one that is still in the process of closing.
1382    /// For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO.REUSEADDR).
1383    /// Client applications usually need not call bind at all—connect chooses an unused port automatically.
1384    /// When bind is called with a wildcard address (involving ADDR_ANY), a WSAEADDRINUSE error could be delayed until the specific address is committed.
1385    /// This could happen with a call to another function later, including connect, listen, WSAConnect, or WSAJoinLeaf.
1386    WSAEADDRINUSE = 10048,
1387
1388    /// Cannot assign requested address.
1389    /// The requested address is not valid in its context.
1390    /// This normally results from an attempt to bind to an address that is not valid for the local computer.
1391    /// This can also result from connect, sendto, WSAConnect, WSAJoinLeaf, or WSASendTo when the remote address or port is not valid for a remote computer (for example, address or port 0).
1392    WSAEADDRNOTAVAIL = 10049,
1393
1394    /// Network is down.
1395    /// A socket operation encountered a dead network.
1396    /// This could indicate a serious failure of the network system (that is, the protocol stack that the Windows Sockets DLL runs over), the network interface, or the local network itself.
1397    WSAENETDOWN = 10050,
1398
1399    /// Network is unreachable.
1400    /// A socket operation was attempted to an unreachable network.
1401    /// This usually means the local software knows no route to reach the remote host.
1402    WSAENETUNREACH = 10051,
1403
1404    /// Network dropped connection on reset.
1405    /// The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
1406    /// It can also be returned by setsockopt if an attempt is made to set SO.KEEPALIVE on a connection that has already failed.
1407    WSAENETRESET = 10052,
1408
1409    /// Software caused connection abort.
1410    /// An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error.
1411    WSAECONNABORTED = 10053,
1412
1413    /// Connection reset by peer.
1414    /// An existing connection was forcibly closed by the remote host.
1415    /// This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO.LINGER option on the remote socket).
1416    /// This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress.
1417    /// Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
1418    WSAECONNRESET = 10054,
1419
1420    /// No buffer space available.
1421    /// An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
1422    WSAENOBUFS = 10055,
1423
1424    /// Socket is already connected.
1425    /// A connect request was made on an already-connected socket.
1426    /// Some implementations also return this error if sendto is called on a connected SOCK.DGRAM socket (for SOCK.STREAM sockets, the to parameter in sendto is ignored) although other implementations treat this as a legal occurrence.
1427    WSAEISCONN = 10056,
1428
1429    /// Socket is not connected.
1430    /// A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied.
1431    /// Any other type of operation might also return this error—for example, setsockopt setting SO.KEEPALIVE if the connection has been reset.
1432    WSAENOTCONN = 10057,
1433
1434    /// Cannot send after socket shutdown.
1435    /// A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call.
1436    /// By calling shutdown a partial close of a socket is requested, which is a signal that sending or receiving, or both have been discontinued.
1437    WSAESHUTDOWN = 10058,
1438
1439    /// Too many references.
1440    /// Too many references to some kernel object.
1441    WSAETOOMANYREFS = 10059,
1442
1443    /// Connection timed out.
1444    /// A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond.
1445    WSAETIMEDOUT = 10060,
1446
1447    /// Connection refused.
1448    /// No connection could be made because the target computer actively refused it.
1449    /// This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.
1450    WSAECONNREFUSED = 10061,
1451
1452    /// Cannot translate name.
1453    /// Cannot translate a name.
1454    WSAELOOP = 10062,
1455
1456    /// Name too long.
1457    /// A name component or a name was too long.
1458    WSAENAMETOOLONG = 10063,
1459
1460    /// Host is down.
1461    /// A socket operation failed because the destination host is down. A socket operation encountered a dead host.
1462    /// Networking activity on the local host has not been initiated.
1463    /// These conditions are more likely to be indicated by the error WSAETIMEDOUT.
1464    WSAEHOSTDOWN = 10064,
1465
1466    /// No route to host.
1467    /// A socket operation was attempted to an unreachable host. See WSAENETUNREACH.
1468    WSAEHOSTUNREACH = 10065,
1469
1470    /// Directory not empty.
1471    /// Cannot remove a directory that is not empty.
1472    WSAENOTEMPTY = 10066,
1473
1474    /// Too many processes.
1475    /// A Windows Sockets implementation may have a limit on the number of applications that can use it simultaneously.
1476    /// WSAStartup may fail with this error if the limit has been reached.
1477    WSAEPROCLIM = 10067,
1478
1479    /// User quota exceeded.
1480    /// Ran out of user quota.
1481    WSAEUSERS = 10068,
1482
1483    /// Disk quota exceeded.
1484    /// Ran out of disk quota.
1485    WSAEDQUOT = 10069,
1486
1487    /// Stale file handle reference.
1488    /// The file handle reference is no longer available.
1489    WSAESTALE = 10070,
1490
1491    /// Item is remote.
1492    /// The item is not available locally.
1493    WSAEREMOTE = 10071,
1494
1495    /// Network subsystem is unavailable.
1496    /// This error is returned by WSAStartup if the Windows Sockets implementation cannot function at this time because the underlying system it uses to provide network services is currently unavailable.
1497    /// Users should check:
1498    ///   - That the appropriate Windows Sockets DLL file is in the current path.
1499    ///   - That they are not trying to use more than one Windows Sockets implementation simultaneously.
1500    ///   - If there is more than one Winsock DLL on your system, be sure the first one in the path is appropriate for the network subsystem currently loaded.
1501    ///   - The Windows Sockets implementation documentation to be sure all necessary components are currently installed and configured correctly.
1502    WSASYSNOTREADY = 10091,
1503
1504    /// Winsock.dll version out of range.
1505    /// The current Windows Sockets implementation does not support the Windows Sockets specification version requested by the application.
1506    /// Check that no old Windows Sockets DLL files are being accessed.
1507    WSAVERNOTSUPPORTED = 10092,
1508
1509    /// Successful WSAStartup not yet performed.
1510    /// Either the application has not called WSAStartup or WSAStartup failed.
1511    /// The application may be accessing a socket that the current active task does not own (that is, trying to share a socket between tasks), or WSACleanup has been called too many times.
1512    WSANOTINITIALISED = 10093,
1513
1514    /// Graceful shutdown in progress.
1515    /// Returned by WSARecv and WSARecvFrom to indicate that the remote party has initiated a graceful shutdown sequence.
1516    WSAEDISCON = 10101,
1517
1518    /// No more results.
1519    /// No more results can be returned by the WSALookupServiceNext function.
1520    WSAENOMORE = 10102,
1521
1522    /// Call has been canceled.
1523    /// A call to the WSALookupServiceEnd function was made while this call was still processing. The call has been canceled.
1524    WSAECANCELLED = 10103,
1525
1526    /// Procedure call table is invalid.
1527    /// The service provider procedure call table is invalid.
1528    /// A service provider returned a bogus procedure table to Ws2_32.dll.
1529    /// This is usually caused by one or more of the function pointers being NULL.
1530    WSAEINVALIDPROCTABLE = 10104,
1531
1532    /// Service provider is invalid.
1533    /// The requested service provider is invalid.
1534    /// This error is returned by the WSCGetProviderInfo and WSCGetProviderInfo32 functions if the protocol entry specified could not be found.
1535    /// This error is also returned if the service provider returned a version number other than 2.0.
1536    WSAEINVALIDPROVIDER = 10105,
1537
1538    /// Service provider failed to initialize.
1539    /// The requested service provider could not be loaded or initialized.
1540    /// This error is returned if either a service provider's DLL could not be loaded (LoadLibrary failed) or the provider's WSPStartup or NSPStartup function failed.
1541    WSAEPROVIDERFAILEDINIT = 10106,
1542
1543    /// System call failure.
1544    /// A system call that should never fail has failed.
1545    /// This is a generic error code, returned under various conditions.
1546    /// Returned when a system call that should never fail does fail.
1547    /// For example, if a call to WaitForMultipleEvents fails or one of the registry functions fails trying to manipulate the protocol/namespace catalogs.
1548    /// Returned when a provider does not return SUCCESS and does not provide an extended error code.
1549    /// Can indicate a service provider implementation error.
1550    WSASYSCALLFAILURE = 10107,
1551
1552    /// Service not found.
1553    /// No such service is known. The service cannot be found in the specified name space.
1554    WSASERVICE_NOT_FOUND = 10108,
1555
1556    /// Class type not found.
1557    /// The specified class was not found.
1558    WSATYPE_NOT_FOUND = 10109,
1559
1560    /// No more results.
1561    /// No more results can be returned by the WSALookupServiceNext function.
1562    WSA_E_NO_MORE = 10110,
1563
1564    /// Call was canceled.
1565    /// A call to the WSALookupServiceEnd function was made while this call was still processing. The call has been canceled.
1566    WSA_E_CANCELLED = 10111,
1567
1568    /// Database query was refused.
1569    /// A database query failed because it was actively refused.
1570    WSAEREFUSED = 10112,
1571
1572    /// Host not found.
1573    /// No such host is known. The name is not an official host name or alias, or it cannot be found in the database(s) being queried.
1574    /// This error may also be returned for protocol and service queries, and means that the specified name could not be found in the relevant database.
1575    WSAHOST_NOT_FOUND = 11001,
1576
1577    /// Nonauthoritative host not found.
1578    /// This is usually a temporary error during host name resolution and means that the local server did not receive a response from an authoritative server. A retry at some time later may be successful.
1579    WSATRY_AGAIN = 11002,
1580
1581    /// This is a nonrecoverable error.
1582    /// This indicates that some sort of nonrecoverable error occurred during a database lookup.
1583    /// This may be because the database files (for example, BSD-compatible HOSTS, SERVICES, or PROTOCOLS files) could not be found, or a DNS request was returned by the server with a severe error.
1584    WSANO_RECOVERY = 11003,
1585
1586    /// Valid name, no data record of requested type.
1587    /// The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for.
1588    /// The usual example for this is a host name-to-address translation attempt (using gethostbyname or WSAAsyncGetHostByName) which uses the DNS (Domain Name Server).
1589    /// An MX record is returned but no A record—indicating the host itself exists, but is not directly reachable.
1590    WSANO_DATA = 11004,
1591
1592    /// QoS receivers.
1593    /// At least one QoS reserve has arrived.
1594    WSA_QOS_RECEIVERS = 11005,
1595
1596    /// QoS senders.
1597    /// At least one QoS send path has arrived.
1598    WSA_QOS_SENDERS = 11006,
1599
1600    /// No QoS senders.
1601    /// There are no QoS senders.
1602    WSA_QOS_NO_SENDERS = 11007,
1603
1604    /// QoS no receivers.
1605    /// There are no QoS receivers.
1606    WSA_QOS_NO_RECEIVERS = 11008,
1607
1608    /// QoS request confirmed.
1609    /// The QoS reserve request has been confirmed.
1610    WSA_QOS_REQUEST_CONFIRMED = 11009,
1611
1612    /// QoS admission error.
1613    /// A QoS error occurred due to lack of resources.
1614    WSA_QOS_ADMISSION_FAILURE = 11010,
1615
1616    /// QoS policy failure.
1617    /// The QoS request was rejected because the policy system couldn't allocate the requested resource within the existing policy.
1618    WSA_QOS_POLICY_FAILURE = 11011,
1619
1620    /// QoS bad style.
1621    /// An unknown or conflicting QoS style was encountered.
1622    WSA_QOS_BAD_STYLE = 11012,
1623
1624    /// QoS bad object.
1625    /// A problem was encountered with some part of the filterspec or the provider-specific buffer in general.
1626    WSA_QOS_BAD_OBJECT = 11013,
1627
1628    /// QoS traffic control error.
1629    /// An error with the underlying traffic control (TC) API as the generic QoS request was converted for local enforcement by the TC API.
1630    /// This could be due to an out of memory error or to an internal QoS provider error.
1631    WSA_QOS_TRAFFIC_CTRL_ERROR = 11014,
1632
1633    /// QoS generic error.
1634    /// A general QoS error.
1635    WSA_QOS_GENERIC_ERROR = 11015,
1636
1637    /// QoS service type error.
1638    /// An invalid or unrecognized service type was found in the QoS flowspec.
1639    WSA_QOS_ESERVICETYPE = 11016,
1640
1641    /// QoS flowspec error.
1642    /// An invalid or inconsistent flowspec was found in the QOS structure.
1643    WSA_QOS_EFLOWSPEC = 11017,
1644
1645    /// Invalid QoS provider buffer.
1646    /// An invalid QoS provider-specific buffer.
1647    WSA_QOS_EPROVSPECBUF = 11018,
1648
1649    /// Invalid QoS filter style.
1650    /// An invalid QoS filter style was used.
1651    WSA_QOS_EFILTERSTYLE = 11019,
1652
1653    /// Invalid QoS filter type.
1654    /// An invalid QoS filter type was used.
1655    WSA_QOS_EFILTERTYPE = 11020,
1656
1657    /// Incorrect QoS filter count.
1658    /// An incorrect number of QoS FILTERSPECs were specified in the FLOWDESCRIPTOR.
1659    WSA_QOS_EFILTERCOUNT = 11021,
1660
1661    /// Invalid QoS object length.
1662    /// An object with an invalid ObjectLength field was specified in the QoS provider-specific buffer.
1663    WSA_QOS_EOBJLENGTH = 11022,
1664
1665    /// Incorrect QoS flow count.
1666    /// An incorrect number of flow descriptors was specified in the QoS structure.
1667    WSA_QOS_EFLOWCOUNT = 11023,
1668
1669    /// Unrecognized QoS object.
1670    /// An unrecognized object was found in the QoS provider-specific buffer.
1671    WSA_QOS_EUNKOWNPSOBJ = 11024,
1672
1673    /// Invalid QoS policy object.
1674    /// An invalid policy object was found in the QoS provider-specific buffer.
1675    WSA_QOS_EPOLICYOBJ = 11025,
1676
1677    /// Invalid QoS flow descriptor.
1678    /// An invalid QoS flow descriptor was found in the flow descriptor list.
1679    WSA_QOS_EFLOWDESC = 11026,
1680
1681    /// Invalid QoS provider-specific flowspec.
1682    /// An invalid or inconsistent flowspec was found in the QoS provider-specific buffer.
1683    WSA_QOS_EPSFLOWSPEC = 11027,
1684
1685    /// Invalid QoS provider-specific filterspec.
1686    /// An invalid FILTERSPEC was found in the QoS provider-specific buffer.
1687    WSA_QOS_EPSFILTERSPEC = 11028,
1688
1689    /// Invalid QoS shape discard mode object.
1690    /// An invalid shape discard mode object was found in the QoS provider-specific buffer.
1691    WSA_QOS_ESDMODEOBJ = 11029,
1692
1693    /// Invalid QoS shaping rate object.
1694    /// An invalid shaping rate object was found in the QoS provider-specific buffer.
1695    WSA_QOS_ESHAPERATEOBJ = 11030,
1696
1697    /// Reserved policy QoS element type.
1698    /// A reserved policy element was found in the QoS provider-specific buffer.
1699    WSA_QOS_RESERVED_PETYPE = 11031,
1700
1701    _,
1702};
1703
1704pub extern "ws2_32" fn accept(
1705    s: SOCKET,
1706    addr: ?*sockaddr,
1707    addrlen: ?*i32,
1708) callconv(WINAPI) SOCKET;
1709
1710pub extern "ws2_32" fn bind(
1711    s: SOCKET,
1712    name: *const sockaddr,
1713    namelen: i32,
1714) callconv(WINAPI) i32;
1715
1716pub extern "ws2_32" fn closesocket(
1717    s: SOCKET,
1718) callconv(WINAPI) i32;
1719
1720pub extern "ws2_32" fn connect(
1721    s: SOCKET,
1722    name: *const sockaddr,
1723    namelen: i32,
1724) callconv(WINAPI) i32;
1725
1726pub extern "ws2_32" fn ioctlsocket(
1727    s: SOCKET,
1728    cmd: i32,
1729    argp: *u32,
1730) callconv(WINAPI) i32;
1731
1732pub extern "ws2_32" fn getpeername(
1733    s: SOCKET,
1734    name: *sockaddr,
1735    namelen: *i32,
1736) callconv(WINAPI) i32;
1737
1738pub extern "ws2_32" fn getsockname(
1739    s: SOCKET,
1740    name: *sockaddr,
1741    namelen: *i32,
1742) callconv(WINAPI) i32;
1743
1744pub extern "ws2_32" fn getsockopt(
1745    s: SOCKET,
1746    level: i32,
1747    optname: i32,
1748    optval: [*]u8,
1749    optlen: *i32,
1750) callconv(WINAPI) i32;
1751
1752pub extern "ws2_32" fn htonl(
1753    hostlong: u32,
1754) callconv(WINAPI) u32;
1755
1756pub extern "ws2_32" fn htons(
1757    hostshort: u16,
1758) callconv(WINAPI) u16;
1759
1760pub extern "ws2_32" fn inet_addr(
1761    cp: ?[*]const u8,
1762) callconv(WINAPI) u32;
1763
1764pub extern "ws2_32" fn listen(
1765    s: SOCKET,
1766    backlog: i32,
1767) callconv(WINAPI) i32;
1768
1769pub extern "ws2_32" fn ntohl(
1770    netlong: u32,
1771) callconv(WINAPI) u32;
1772
1773pub extern "ws2_32" fn ntohs(
1774    netshort: u16,
1775) callconv(WINAPI) u16;
1776
1777pub extern "ws2_32" fn recv(
1778    s: SOCKET,
1779    buf: [*]u8,
1780    len: i32,
1781    flags: i32,
1782) callconv(WINAPI) i32;
1783
1784pub extern "ws2_32" fn recvfrom(
1785    s: SOCKET,
1786    buf: [*]u8,
1787    len: i32,
1788    flags: i32,
1789    from: ?*sockaddr,
1790    fromlen: ?*i32,
1791) callconv(WINAPI) i32;
1792
1793pub extern "ws2_32" fn select(
1794    nfds: i32,
1795    readfds: ?*fd_set,
1796    writefds: ?*fd_set,
1797    exceptfds: ?*fd_set,
1798    timeout: ?*const timeval,
1799) callconv(WINAPI) i32;
1800
1801pub extern "ws2_32" fn send(
1802    s: SOCKET,
1803    buf: [*]const u8,
1804    len: i32,
1805    flags: u32,
1806) callconv(WINAPI) i32;
1807
1808pub extern "ws2_32" fn sendto(
1809    s: SOCKET,
1810    buf: [*]const u8,
1811    len: i32,
1812    flags: i32,
1813    to: *const sockaddr,
1814    tolen: i32,
1815) callconv(WINAPI) i32;
1816
1817pub extern "ws2_32" fn setsockopt(
1818    s: SOCKET,
1819    level: i32,
1820    optname: i32,
1821    optval: ?[*]const u8,
1822    optlen: i32,
1823) callconv(WINAPI) i32;
1824
1825pub extern "ws2_32" fn shutdown(
1826    s: SOCKET,
1827    how: i32,
1828) callconv(WINAPI) i32;
1829
1830pub extern "ws2_32" fn socket(
1831    af: i32,
1832    @"type": i32,
1833    protocol: i32,
1834) callconv(WINAPI) SOCKET;
1835
1836pub extern "ws2_32" fn WSAStartup(
1837    wVersionRequired: WORD,
1838    lpWSAData: *WSADATA,
1839) callconv(WINAPI) i32;
1840
1841pub extern "ws2_32" fn WSACleanup() callconv(WINAPI) i32;
1842
1843pub extern "ws2_32" fn WSASetLastError(iError: i32) callconv(WINAPI) void;
1844
1845pub extern "ws2_32" fn WSAGetLastError() callconv(WINAPI) WinsockError;
1846
1847pub extern "ws2_32" fn WSAIsBlocking() callconv(WINAPI) BOOL;
1848
1849pub extern "ws2_32" fn WSAUnhookBlockingHook() callconv(WINAPI) i32;
1850
1851pub extern "ws2_32" fn WSASetBlockingHook(lpBlockFunc: FARPROC) callconv(WINAPI) FARPROC;
1852
1853pub extern "ws2_32" fn WSACancelBlockingCall() callconv(WINAPI) i32;
1854
1855pub extern "ws2_32" fn WSAAsyncGetServByName(
1856    hWnd: HWND,
1857    wMsg: u32,
1858    name: [*:0]const u8,
1859    proto: ?[*:0]const u8,
1860    buf: [*]u8,
1861    buflen: i32,
1862) callconv(WINAPI) HANDLE;
1863
1864pub extern "ws2_32" fn WSAAsyncGetServByPort(
1865    hWnd: HWND,
1866    wMsg: u32,
1867    port: i32,
1868    proto: ?[*:0]const u8,
1869    buf: [*]u8,
1870    buflen: i32,
1871) callconv(WINAPI) HANDLE;
1872
1873pub extern "ws2_32" fn WSAAsyncGetProtoByName(
1874    hWnd: HWND,
1875    wMsg: u32,
1876    name: [*:0]const u8,
1877    buf: [*]u8,
1878    buflen: i32,
1879) callconv(WINAPI) HANDLE;
1880
1881pub extern "ws2_32" fn WSAAsyncGetProtoByNumber(
1882    hWnd: HWND,
1883    wMsg: u32,
1884    number: i32,
1885    buf: [*]u8,
1886    buflen: i32,
1887) callconv(WINAPI) HANDLE;
1888
1889pub extern "ws2_32" fn WSACancelAsyncRequest(hAsyncTaskHandle: HANDLE) callconv(WINAPI) i32;
1890
1891pub extern "ws2_32" fn WSAAsyncSelect(
1892    s: SOCKET,
1893    hWnd: HWND,
1894    wMsg: u32,
1895    lEvent: i32,
1896) callconv(WINAPI) i32;
1897
1898pub extern "ws2_32" fn WSAAccept(
1899    s: SOCKET,
1900    addr: ?*sockaddr,
1901    addrlen: ?*i32,
1902    lpfnCondition: ?LPCONDITIONPROC,
1903    dwCallbackData: usize,
1904) callconv(WINAPI) SOCKET;
1905
1906pub extern "ws2_32" fn WSACloseEvent(hEvent: HANDLE) callconv(WINAPI) BOOL;
1907
1908pub extern "ws2_32" fn WSAConnect(
1909    s: SOCKET,
1910    name: *const sockaddr,
1911    namelen: i32,
1912    lpCallerData: ?*WSABUF,
1913    lpCalleeData: ?*WSABUF,
1914    lpSQOS: ?*QOS,
1915    lpGQOS: ?*QOS,
1916) callconv(WINAPI) i32;
1917
1918pub extern "ws2_32" fn WSAConnectByNameW(
1919    s: SOCKET,
1920    nodename: [*:0]const u16,
1921    servicename: [*:0]const u16,
1922    LocalAddressLength: ?*u32,
1923    LocalAddress: ?*sockaddr,
1924    RemoteAddressLength: ?*u32,
1925    RemoteAddress: ?*sockaddr,
1926    timeout: ?*const timeval,
1927    Reserved: *OVERLAPPED,
1928) callconv(WINAPI) BOOL;
1929
1930pub extern "ws2_32" fn WSAConnectByNameA(
1931    s: SOCKET,
1932    nodename: [*:0]const u8,
1933    servicename: [*:0]const u8,
1934    LocalAddressLength: ?*u32,
1935    LocalAddress: ?*sockaddr,
1936    RemoteAddressLength: ?*u32,
1937    RemoteAddress: ?*sockaddr,
1938    timeout: ?*const timeval,
1939    Reserved: *OVERLAPPED,
1940) callconv(WINAPI) BOOL;
1941
1942pub extern "ws2_32" fn WSAConnectByList(
1943    s: SOCKET,
1944    SocketAddress: *SOCKET_ADDRESS_LIST,
1945    LocalAddressLength: ?*u32,
1946    LocalAddress: ?*sockaddr,
1947    RemoteAddressLength: ?*u32,
1948    RemoteAddress: ?*sockaddr,
1949    timeout: ?*const timeval,
1950    Reserved: *OVERLAPPED,
1951) callconv(WINAPI) BOOL;
1952
1953pub extern "ws2_32" fn WSACreateEvent() callconv(WINAPI) HANDLE;
1954
1955pub extern "ws2_32" fn WSADuplicateSocketA(
1956    s: SOCKET,
1957    dwProcessId: u32,
1958    lpProtocolInfo: *WSAPROTOCOL_INFOA,
1959) callconv(WINAPI) i32;
1960
1961pub extern "ws2_32" fn WSADuplicateSocketW(
1962    s: SOCKET,
1963    dwProcessId: u32,
1964    lpProtocolInfo: *WSAPROTOCOL_INFOW,
1965) callconv(WINAPI) i32;
1966
1967pub extern "ws2_32" fn WSAEnumNetworkEvents(
1968    s: SOCKET,
1969    hEventObject: HANDLE,
1970    lpNetworkEvents: *WSANETWORKEVENTS,
1971) callconv(WINAPI) i32;
1972
1973pub extern "ws2_32" fn WSAEnumProtocolsA(
1974    lpiProtocols: ?*i32,
1975    lpProtocolBuffer: ?*WSAPROTOCOL_INFOA,
1976    lpdwBufferLength: *u32,
1977) callconv(WINAPI) i32;
1978
1979pub extern "ws2_32" fn WSAEnumProtocolsW(
1980    lpiProtocols: ?*i32,
1981    lpProtocolBuffer: ?*WSAPROTOCOL_INFOW,
1982    lpdwBufferLength: *u32,
1983) callconv(WINAPI) i32;
1984
1985pub extern "ws2_32" fn WSAEventSelect(
1986    s: SOCKET,
1987    hEventObject: HANDLE,
1988    lNetworkEvents: i32,
1989) callconv(WINAPI) i32;
1990
1991pub extern "ws2_32" fn WSAGetOverlappedResult(
1992    s: SOCKET,
1993    lpOverlapped: *OVERLAPPED,
1994    lpcbTransfer: *u32,
1995    fWait: BOOL,
1996    lpdwFlags: *u32,
1997) callconv(WINAPI) BOOL;
1998
1999pub extern "ws2_32" fn WSAGetQOSByName(
2000    s: SOCKET,
2001    lpQOSName: *WSABUF,
2002    lpQOS: *QOS,
2003) callconv(WINAPI) BOOL;
2004
2005pub extern "ws2_32" fn WSAHtonl(
2006    s: SOCKET,
2007    hostlong: u32,
2008    lpnetlong: *u32,
2009) callconv(WINAPI) i32;
2010
2011pub extern "ws2_32" fn WSAHtons(
2012    s: SOCKET,
2013    hostshort: u16,
2014    lpnetshort: *u16,
2015) callconv(WINAPI) i32;
2016
2017pub extern "ws2_32" fn WSAIoctl(
2018    s: SOCKET,
2019    dwIoControlCode: u32,
2020    lpvInBuffer: ?*const anyopaque,
2021    cbInBuffer: u32,
2022    lpvOutbuffer: ?*anyopaque,
2023    cbOutbuffer: u32,
2024    lpcbBytesReturned: *u32,
2025    lpOverlapped: ?*OVERLAPPED,
2026    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2027) callconv(WINAPI) i32;
2028
2029pub extern "ws2_32" fn WSAJoinLeaf(
2030    s: SOCKET,
2031    name: *const sockaddr,
2032    namelen: i32,
2033    lpCallerdata: ?*WSABUF,
2034    lpCalleeData: ?*WSABUF,
2035    lpSQOS: ?*QOS,
2036    lpGQOS: ?*QOS,
2037    dwFlags: u32,
2038) callconv(WINAPI) SOCKET;
2039
2040pub extern "ws2_32" fn WSANtohl(
2041    s: SOCKET,
2042    netlong: u32,
2043    lphostlong: *u32,
2044) callconv(WINAPI) u32;
2045
2046pub extern "ws2_32" fn WSANtohs(
2047    s: SOCKET,
2048    netshort: u16,
2049    lphostshort: *u16,
2050) callconv(WINAPI) i32;
2051
2052pub extern "ws2_32" fn WSARecv(
2053    s: SOCKET,
2054    lpBuffers: [*]WSABUF,
2055    dwBufferCouynt: u32,
2056    lpNumberOfBytesRecv: ?*u32,
2057    lpFlags: *u32,
2058    lpOverlapped: ?*OVERLAPPED,
2059    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2060) callconv(WINAPI) i32;
2061
2062pub extern "ws2_32" fn WSARecvDisconnect(
2063    s: SOCKET,
2064    lpInboundDisconnectData: ?*WSABUF,
2065) callconv(WINAPI) i32;
2066
2067pub extern "ws2_32" fn WSARecvFrom(
2068    s: SOCKET,
2069    lpBuffers: [*]WSABUF,
2070    dwBuffercount: u32,
2071    lpNumberOfBytesRecvd: ?*u32,
2072    lpFlags: *u32,
2073    lpFrom: ?*sockaddr,
2074    lpFromlen: ?*i32,
2075    lpOverlapped: ?*OVERLAPPED,
2076    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2077) callconv(WINAPI) i32;
2078
2079pub extern "ws2_32" fn WSAResetEvent(hEvent: HANDLE) callconv(WINAPI) i32;
2080
2081pub extern "ws2_32" fn WSASend(
2082    s: SOCKET,
2083    lpBuffers: [*]WSABUF,
2084    dwBufferCount: u32,
2085    lpNumberOfBytesSent: ?*u32,
2086    dwFlags: u32,
2087    lpOverlapped: ?*OVERLAPPED,
2088    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2089) callconv(WINAPI) i32;
2090
2091pub extern "ws2_32" fn WSASendMsg(
2092    s: SOCKET,
2093    lpMsg: *const std.x.os.Socket.Message,
2094    dwFlags: u32,
2095    lpNumberOfBytesSent: ?*u32,
2096    lpOverlapped: ?*OVERLAPPED,
2097    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2098) callconv(WINAPI) i32;
2099
2100pub extern "ws2_32" fn WSARecvMsg(
2101    s: SOCKET,
2102    lpMsg: *std.x.os.Socket.Message,
2103    lpdwNumberOfBytesRecv: ?*u32,
2104    lpOverlapped: ?*OVERLAPPED,
2105    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2106) callconv(WINAPI) i32;
2107
2108pub extern "ws2_32" fn WSASendDisconnect(
2109    s: SOCKET,
2110    lpOutboundDisconnectData: ?*WSABUF,
2111) callconv(WINAPI) i32;
2112
2113pub extern "ws2_32" fn WSASendTo(
2114    s: SOCKET,
2115    lpBuffers: [*]WSABUF,
2116    dwBufferCount: u32,
2117    lpNumberOfBytesSent: ?*u32,
2118    dwFlags: u32,
2119    lpTo: ?*const sockaddr,
2120    iToLen: i32,
2121    lpOverlapped: ?*OVERLAPPED,
2122    lpCompletionRounte: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2123) callconv(WINAPI) i32;
2124
2125pub extern "ws2_32" fn WSASetEvent(
2126    hEvent: HANDLE,
2127) callconv(WINAPI) BOOL;
2128
2129pub extern "ws2_32" fn WSASocketA(
2130    af: i32,
2131    @"type": i32,
2132    protocol: i32,
2133    lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
2134    g: u32,
2135    dwFlags: u32,
2136) callconv(WINAPI) SOCKET;
2137
2138pub extern "ws2_32" fn WSASocketW(
2139    af: i32,
2140    @"type": i32,
2141    protocol: i32,
2142    lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
2143    g: u32,
2144    dwFlags: u32,
2145) callconv(WINAPI) SOCKET;
2146
2147pub extern "ws2_32" fn WSAWaitForMultipleEvents(
2148    cEvents: u32,
2149    lphEvents: [*]const HANDLE,
2150    fWaitAll: BOOL,
2151    dwTimeout: u32,
2152    fAlertable: BOOL,
2153) callconv(WINAPI) u32;
2154
2155pub extern "ws2_32" fn WSAAddressToStringA(
2156    lpsaAddress: *sockaddr,
2157    dwAddressLength: u32,
2158    lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
2159    lpszAddressString: [*]u8,
2160    lpdwAddressStringLength: *u32,
2161) callconv(WINAPI) i32;
2162
2163pub extern "ws2_32" fn WSAAddressToStringW(
2164    lpsaAddress: *sockaddr,
2165    dwAddressLength: u32,
2166    lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
2167    lpszAddressString: [*]u16,
2168    lpdwAddressStringLength: *u32,
2169) callconv(WINAPI) i32;
2170
2171pub extern "ws2_32" fn WSAStringToAddressA(
2172    AddressString: [*:0]const u8,
2173    AddressFamily: i32,
2174    lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
2175    lpAddress: *sockaddr,
2176    lpAddressLength: *i32,
2177) callconv(WINAPI) i32;
2178
2179pub extern "ws2_32" fn WSAStringToAddressW(
2180    AddressString: [*:0]const u16,
2181    AddressFamily: i32,
2182    lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
2183    lpAddrses: *sockaddr,
2184    lpAddressLength: *i32,
2185) callconv(WINAPI) i32;
2186
2187pub extern "ws2_32" fn WSAProviderConfigChange(
2188    lpNotificationHandle: *HANDLE,
2189    lpOverlapped: ?*OVERLAPPED,
2190    lpCompletionRoutine: ?LPWSAOVERLAPPED_COMPLETION_ROUTINE,
2191) callconv(WINAPI) i32;
2192
2193pub extern "ws2_32" fn WSAPoll(
2194    fdArray: [*]WSAPOLLFD,
2195    fds: u32,
2196    timeout: i32,
2197) callconv(WINAPI) i32;
2198
2199pub extern "mswsock" fn WSARecvEx(
2200    s: SOCKET,
2201    buf: [*]u8,
2202    len: i32,
2203    flags: *i32,
2204) callconv(WINAPI) i32;
2205
2206pub extern "mswsock" fn TransmitFile(
2207    hSocket: SOCKET,
2208    hFile: HANDLE,
2209    nNumberOfBytesToWrite: u32,
2210    nNumberOfBytesPerSend: u32,
2211    lpOverlapped: ?*OVERLAPPED,
2212    lpTransmitBuffers: ?*TRANSMIT_FILE_BUFFERS,
2213    dwReserved: u32,
2214) callconv(WINAPI) BOOL;
2215
2216pub extern "mswsock" fn AcceptEx(
2217    sListenSocket: SOCKET,
2218    sAcceptSocket: SOCKET,
2219    lpOutputBuffer: *anyopaque,
2220    dwReceiveDataLength: u32,
2221    dwLocalAddressLength: u32,
2222    dwRemoteAddressLength: u32,
2223    lpdwBytesReceived: *u32,
2224    lpOverlapped: *OVERLAPPED,
2225) callconv(WINAPI) BOOL;
2226
2227pub extern "mswsock" fn GetAcceptExSockaddrs(
2228    lpOutputBuffer: *anyopaque,
2229    dwReceiveDataLength: u32,
2230    dwLocalAddressLength: u32,
2231    dwRemoteAddressLength: u32,
2232    LocalSockaddr: **sockaddr,
2233    LocalSockaddrLength: *i32,
2234    RemoteSockaddr: **sockaddr,
2235    RemoteSockaddrLength: *i32,
2236) callconv(WINAPI) void;
2237
2238pub extern "ws2_32" fn WSAProviderCompleteAsyncCall(
2239    hAsyncCall: HANDLE,
2240    iRetCode: i32,
2241) callconv(WINAPI) i32;
2242
2243pub extern "mswsock" fn EnumProtocolsA(
2244    lpiProtocols: ?*i32,
2245    lpProtocolBuffer: *anyopaque,
2246    lpdwBufferLength: *u32,
2247) callconv(WINAPI) i32;
2248
2249pub extern "mswsock" fn EnumProtocolsW(
2250    lpiProtocols: ?*i32,
2251    lpProtocolBuffer: *anyopaque,
2252    lpdwBufferLength: *u32,
2253) callconv(WINAPI) i32;
2254
2255pub extern "mswsock" fn GetAddressByNameA(
2256    dwNameSpace: u32,
2257    lpServiceType: *GUID,
2258    lpServiceName: ?[*:0]u8,
2259    lpiProtocols: ?*i32,
2260    dwResolution: u32,
2261    lpServiceAsyncInfo: ?*SERVICE_ASYNC_INFO,
2262    lpCsaddrBuffer: *anyopaque,
2263    lpAliasBuffer: ?[*:0]const u8,
2264    lpdwAliasBufferLength: *u32,
2265) callconv(WINAPI) i32;
2266
2267pub extern "mswsock" fn GetAddressByNameW(
2268    dwNameSpace: u32,
2269    lpServiceType: *GUID,
2270    lpServiceName: ?[*:0]u16,
2271    lpiProtocols: ?*i32,
2272    dwResolution: u32,
2273    lpServiceAsyncInfo: ?*SERVICE_ASYNC_INFO,
2274    lpCsaddrBuffer: *anyopaque,
2275    ldwBufferLEngth: *u32,
2276    lpAliasBuffer: ?[*:0]u16,
2277    lpdwAliasBufferLength: *u32,
2278) callconv(WINAPI) i32;
2279
2280pub extern "mswsock" fn GetTypeByNameA(
2281    lpServiceName: [*:0]u8,
2282    lpServiceType: *GUID,
2283) callconv(WINAPI) i32;
2284
2285pub extern "mswsock" fn GetTypeByNameW(
2286    lpServiceName: [*:0]u16,
2287    lpServiceType: *GUID,
2288) callconv(WINAPI) i32;
2289
2290pub extern "mswsock" fn GetNameByTypeA(
2291    lpServiceType: *GUID,
2292    lpServiceName: [*:0]u8,
2293    dwNameLength: u32,
2294) callconv(WINAPI) i32;
2295
2296pub extern "mswsock" fn GetNameByTypeW(
2297    lpServiceType: *GUID,
2298    lpServiceName: [*:0]u16,
2299    dwNameLength: u32,
2300) callconv(WINAPI) i32;
2301
2302pub extern "ws2_32" fn getaddrinfo(
2303    pNodeName: ?[*:0]const u8,
2304    pServiceName: ?[*:0]const u8,
2305    pHints: ?*const addrinfoa,
2306    ppResult: **addrinfoa,
2307) callconv(WINAPI) i32;
2308
2309pub extern "ws2_32" fn GetAddrInfoExA(
2310    pName: ?[*:0]const u8,
2311    pServiceName: ?[*:0]const u8,
2312    dwNameSapce: u32,
2313    lpNspId: ?*GUID,
2314    hints: ?*const addrinfoexA,
2315    ppResult: **addrinfoexA,
2316    timeout: ?*timeval,
2317    lpOverlapped: ?*OVERLAPPED,
2318    lpCompletionRoutine: ?LPLOOKUPSERVICE_COMPLETION_ROUTINE,
2319) callconv(WINAPI) i32;
2320
2321pub extern "ws2_32" fn GetAddrInfoExCancel(
2322    lpHandle: *HANDLE,
2323) callconv(WINAPI) i32;
2324
2325pub extern "ws2_32" fn GetAddrInfoExOverlappedResult(
2326    lpOverlapped: *OVERLAPPED,
2327) callconv(WINAPI) i32;
2328
2329pub extern "ws2_32" fn freeaddrinfo(
2330    pAddrInfo: ?*addrinfoa,
2331) callconv(WINAPI) void;
2332
2333pub extern "ws2_32" fn FreeAddrInfoEx(
2334    pAddrInfoEx: ?*addrinfoexA,
2335) callconv(WINAPI) void;
2336
2337pub extern "ws2_32" fn getnameinfo(
2338    pSockaddr: *const sockaddr,
2339    SockaddrLength: i32,
2340    pNodeBuffer: ?[*]u8,
2341    NodeBufferSize: u32,
2342    pServiceBuffer: ?[*]u8,
2343    ServiceBufferName: u32,
2344    Flags: i32,
2345) callconv(WINAPI) i32;
2346
2347pub extern "IPHLPAPI" fn if_nametoindex(
2348    InterfaceName: [*:0]const u8,
2349) callconv(WINAPI) u32;
2350