-
Notifications
You must be signed in to change notification settings - Fork 191
/
ws2def.cs
2263 lines (2062 loc) · 108 KB
/
ws2def.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
#pragma warning disable IDE1006 // Naming Styles
namespace Vanara.PInvoke;
public static partial class Ws2_32
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public const uint IOC_UNIX = 0x00000000;
public const uint IOC_WS2 = 0x08000000;
public const uint IOC_PROTOCOL = 0x10000000;
public const uint IOC_VENDOR = 0x18000000;
public const uint IOC_WSK = 0x0F000000;
public static uint _WSAIO(uint x, uint y) => IOC_VOID|x|y;
public static uint _WSAIOR(uint x, uint y) => IOC_OUT|x|y;
public static uint _WSAIOW(uint x, uint y) => IOC_IN|x|y;
public static uint _WSAIORW(uint x, uint y) => IOC_INOUT|x|y;
public static readonly uint SIO_ASSOCIATE_HANDLE = _WSAIOW(IOC_WS2,1);
public static readonly uint SIO_ENABLE_CIRCULAR_QUEUEING = _WSAIO(IOC_WS2,2);
public static readonly uint SIO_FIND_ROUTE = _WSAIOR(IOC_WS2,3);
public static readonly uint SIO_FLUSH = _WSAIO(IOC_WS2,4);
public static readonly uint SIO_GET_BROADCAST_ADDRESS = _WSAIOR(IOC_WS2,5);
public static readonly uint SIO_GET_EXTENSION_FUNCTION_POINTER = _WSAIORW(IOC_WS2,6);
public static readonly uint SIO_GET_QOS = _WSAIORW(IOC_WS2,7);
public static readonly uint SIO_GET_GROUP_QOS = _WSAIORW(IOC_WS2,8);
public static readonly uint SIO_MULTIPOINT_LOOPBACK = _WSAIOW(IOC_WS2,9);
public static readonly uint SIO_MULTICAST_SCOPE = _WSAIOW(IOC_WS2,10);
public static readonly uint SIO_SET_QOS = _WSAIOW(IOC_WS2,11);
public static readonly uint SIO_SET_GROUP_QOS = _WSAIOW(IOC_WS2,12);
public static readonly uint SIO_TRANSLATE_HANDLE = _WSAIORW(IOC_WS2,13);
public static readonly uint SIO_ROUTING_INTERFACE_QUERY = _WSAIORW(IOC_WS2,20);
public static readonly uint SIO_ROUTING_INTERFACE_CHANGE = _WSAIOW(IOC_WS2,21);
public static readonly uint SIO_ADDRESS_LIST_QUERY = _WSAIOR(IOC_WS2,22);
public static readonly uint SIO_ADDRESS_LIST_CHANGE = _WSAIO(IOC_WS2,23);
public static readonly uint SIO_QUERY_TARGET_PNP_HANDLE = _WSAIOR(IOC_WS2,24);
public static readonly uint SIO_QUERY_RSS_PROCESSOR_INFO = _WSAIOR(IOC_WS2,37);
public static readonly uint SIO_ADDRESS_LIST_SORT = _WSAIORW(IOC_WS2,25);
public static readonly uint SIO_RESERVED_1 = _WSAIOW(IOC_WS2,26);
public static readonly uint SIO_RESERVED_2 = _WSAIOW(IOC_WS2,33);
public static readonly uint SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER = _WSAIORW(IOC_WS2, 36);
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
/// <summary>Flags that indicate options used in the GetAddrInfoW function.</summary>
[PInvokeData("ws2def.h", MSDNShortId = "a4896eac-68ae-4a08-8647-36be65fe4478")]
[Flags]
public enum ADDRINFO_FLAGS : uint
{
/// <summary>The socket address will be used in a call to the bindfunction.</summary>
AI_PASSIVE = 0x01,
/// <summary>The canonical name is returned in the first ai_canonname member.</summary>
AI_CANONNAME = 0x02,
/// <summary>The nodename parameter passed to the GetAddrInfoW function must be a numeric string.</summary>
AI_NUMERICHOST = 0x04,
/// <summary>Servicename must be a numeric port number.</summary>
AI_NUMERICSERV = 0x08,
/// <summary>
/// If this bit is set, a request is made for IPv6 addresses and IPv4 addresses with AI_V4MAPPED.
/// <para>This option is supported on Windows Vista and later.</para>
/// </summary>
AI_ALL = 0x0100,
/// <summary>
/// The GetAddrInfoW will resolve only if a global address is configured. The IPv6 and IPv4 loopback address is not considered a
/// valid global address. This option is only supported on Windows Vista and later.
/// </summary>
AI_ADDRCONFIG = 0x0400,
/// <summary>
/// If the GetAddrInfoW request for an IPv6 addresses fails, a name service request is made for IPv4 addresses and these
/// addresses are converted to IPv4-mapped IPv6 address format.
/// <para>This option is supported on Windows Vista and later.</para>
/// </summary>
AI_V4MAPPED = 0x0800,
/// <summary>
/// The address information can be from a non-authoritative namespace provider.
/// <para>This option is only supported on Windows Vista and later for the NS_EMAIL namespace.</para>
/// </summary>
AI_NON_AUTHORITATIVE = 0x04000,
/// <summary>
/// The address information is from a secure channel.
/// <para>This option is only supported on Windows Vista and later for the NS_EMAIL namespace.</para>
/// </summary>
AI_SECURE = 0x08000,
/// <summary>
/// The address information is for a preferred name for a user.
/// <para>This option is only supported on Windows Vista and later for the NS_EMAIL namespace.</para>
/// </summary>
AI_RETURN_PREFERRED_NAMES = 0x010000,
/// <summary>
/// If a flat name (single label) is specified, GetAddrInfoW will return the fully qualified domain name that the name
/// eventually resolved to. The fully qualified domain name is returned in the ai_canonname member.
/// <para>
/// This is different than AI_CANONNAME bit flag that returns the canonical name registered in DNS which may be different than
/// the fully qualified domain name that the flat name resolved to.
/// </para>
/// <para>
/// Only one of the AI_FQDN and AI_CANONNAME bits can be set. The GetAddrInfoW function will fail if both flags are present with EAI_BADFLAGS.
/// </para>
/// <para>This option is supported on Windows 7, Windows Server 2008 R2, and later.</para>
/// </summary>
AI_FQDN = 0x00020000,
/// <summary>
/// A hint to the namespace provider that the hostname being queried is being used in a file share scenario. The namespace
/// provider may ignore this hint.
/// <para>This option is supported on Windows 7, Windows Server 2008 R2, and later.</para>
/// </summary>
AI_FILESERVER = 0x00040000,
/// <summary>
/// Disable the automatic International Domain Name encoding using Punycode in the name resolution functions called by the
/// GetAddrInfoW function.
/// <para>This option is supported on Windows 8, Windows Server 2012, and later.</para>
/// </summary>
AI_DISABLE_IDN_ENCODING = 0x00080000,
/// <summary>Indicates this is extended ADDRINFOEX(2/..) struct</summary>
AI_EXTENDED = 0x80000000,
/// <summary>Request resolution handle</summary>
AI_RESOLUTION_HANDLE = 0x40000000,
}
/// <summary>Protocols. The IPv6 defines are specified in RFC 2292.</summary>
[PInvokeData("ws2def.h")]
public enum IPPROTO
{
/// <summary/>
IPPROTO_IP = 0,
/// <summary/>
IPPROTO_HOPOPTS = 0,
/// <summary>
/// The Internet Control Message Protocol (ICMP). This is a possible value when the af parameter is AF_UNSPEC, AF_INET, or
/// AF_INET6 and the type parameter is SOCK_RAW or unspecified.
/// <para>This protocol value is supported on Windows XP and later.</para>
/// </summary>
IPPROTO_ICMP = 1,
/// <summary>
/// The Internet Group Management Protocol (IGMP). This is a possible value when the af parameter is AF_UNSPEC, AF_INET, or
/// AF_INET6 and the type parameter is SOCK_RAW or unspecified.
/// <para>This protocol value is supported on Windows XP and later.</para>
/// </summary>
IPPROTO_IGMP = 2,
/// <summary>
/// The Bluetooth Radio Frequency Communications (Bluetooth RFCOMM) protocol. This is a possible value when the af parameter is
/// AF_BTH and the type parameter is SOCK_STREAM.
/// <para>This protocol value is supported on Windows XP with SP2 or later.</para>
/// </summary>
IPPROTO_GGP = 3,
/// <summary/>
IPPROTO_IPV4 = 4,
/// <summary/>
IPPROTO_ST = 5,
/// <summary>
/// The Transmission Control Protocol (TCP). This is a possible value when the af parameter is AF_INET or AF_INET6 and the type
/// parameter is SOCK_STREAM.
/// </summary>
IPPROTO_TCP = 6,
/// <summary/>
IPPROTO_CBT = 7,
/// <summary/>
IPPROTO_EGP = 8,
/// <summary/>
IPPROTO_IGP = 9,
/// <summary/>
IPPROTO_PUP = 12,
/// <summary>
/// The User Datagram Protocol (UDP). This is a possible value when the af parameter is AF_INET or AF_INET6 and the type
/// parameter is SOCK_DGRAM.
/// </summary>
IPPROTO_UDP = 17,
/// <summary/>
IPPROTO_IDP = 22,
/// <summary/>
IPPROTO_RDP = 27,
/// <summary/>
IPPROTO_IPV6 = 41,
/// <summary/>
IPPROTO_ROUTING = 43,
/// <summary/>
IPPROTO_FRAGMENT = 44,
/// <summary/>
IPPROTO_ESP = 50,
/// <summary/>
IPPROTO_AH = 51,
/// <summary>
/// The Internet Control Message Protocol Version 6 (ICMPv6). This is a possible value when the af parameter is AF_UNSPEC,
/// AF_INET, or AF_INET6 and the type parameter is SOCK_RAW or unspecified.
/// <para>This protocol value is supported on Windows XP and later.</para>
/// </summary>
IPPROTO_ICMPV6 = 58,
/// <summary/>
IPPROTO_NONE = 59,
/// <summary/>
IPPROTO_DSTOPTS = 60,
/// <summary/>
IPPROTO_ND = 77,
/// <summary/>
IPPROTO_ICLFXBM = 78,
/// <summary/>
IPPROTO_PIM = 103,
/// <summary>
/// The PGM protocol for reliable multicast. This is a possible value when the af parameter is AF_INET and the type parameter is
/// SOCK_RDM. On the Windows SDK released for Windows Vista and later, this protocol is also called IPPROTO_PGM.
/// <para>This protocol value is only supported if the Reliable Multicast Protocol is installed.</para>
/// </summary>
IPPROTO_PGM = 113,
/// <summary/>
IPPROTO_L2TP = 115,
/// <summary/>
IPPROTO_SCTP = 132,
/// <summary/>
IPPROTO_RAW = 255,
/// <summary/>
IPPROTO_MAX = 256,
/// <summary/>
IPPROTO_RESERVED_RAW = 257,
/// <summary/>
IPPROTO_RESERVED_IPSEC = 258,
/// <summary/>
IPPROTO_RESERVED_IPSECOFFLOAD = 259,
/// <summary/>
IPPROTO_RESERVED_WNV = 260,
/// <summary/>
IPPROTO_RESERVED_MAX = 261
}
/// <summary>Customize processing of the GetNameInfoW function.</summary>
[PInvokeData("ws2def.h", MSDNShortId = "5630a49a-c182-440c-ad54-6ff3ba4274c6")]
public enum NI
{
/// <summary>Results in local hosts having only their Relative Distinguished Name (RDN) returned in the pNodeBuffer parameter.</summary>
NI_NOFQDN = 0x01 /* Only return nodename portion for local hosts */,
/// <summary>
/// Returns the numeric form of the host name instead of its name. The numeric form of the host name is also returned if the
/// host name cannot be resolved by DNS.
/// </summary>
NI_NUMERICHOST = 0x02 /* Return numeric form of the host's address */,
/// <summary>A host name that cannot be resolved by the DNS results in an error.</summary>
NI_NAMEREQD = 0x04 /* Error if the host's name not in DNS */,
/// <summary>
/// Returns the port number of the service instead of its name. Also, if a host name is not found for an IP address (127.0.0.2,
/// for example), the hostname is returned as the IP address.
/// </summary>
NI_NUMERICSERV = 0x08 /* Return numeric form of the service (port #) */,
/// <summary>
/// Indicates that the service is a datagram service. This flag is necessary for the few services that provide different port
/// numbers for UDP and TCP service.
/// </summary>
NI_DGRAM = 0x10 /* Service is a datagram service */,
}
/// <summary>The scope of the IPv6 transport address.</summary>
[PInvokeData("ws2def.h")]
public enum SCOPE_LEVEL
{
/// <summary>The transport address has interface-local scope.</summary>
ScopeLevelInterface = 1,
/// <summary>The transport address has link-local scope.</summary>
ScopeLevelLink = 2,
/// <summary>The transport address has subnet-local scope.</summary>
ScopeLevelSubnet = 3,
/// <summary>The transport address has admin-local scope.</summary>
ScopeLevelAdmin = 4,
/// <summary>The transport address has site-local scope.</summary>
ScopeLevelSite = 5,
/// <summary>The transport address has organization-local scope.</summary>
ScopeLevelOrganization = 8,
/// <summary>The transport address has global scope.</summary>
ScopeLevelGlobal = 14,
/// <summary>The scope level count.</summary>
ScopeLevelCount = 16
}
/// <summary>Gets the size, in bytes, of a <see cref="SOCKET_ADDRESS_LIST"/> given a number of address.</summary>
/// <param name="AddressCount">The address count.</param>
/// <returns>The size, in bytes, required to hold the structure. This does not include allocation for the addresses pointed to by each <see cref="SOCKET_ADDRESS"/>.</returns>
[PInvokeData("ws2def.h")]
public static SizeT SIZEOF_SOCKET_ADDRESS_LIST(SizeT AddressCount) => Marshal.OffsetOf(typeof(SOCKET_ADDRESS_LIST), "Address").ToInt32() + Marshal.SizeOf(typeof(SOCKET_ADDRESS)) * AddressCount;
#if x64
public static readonly SizeT MAX_NATURAL_ALIGNMENT = sizeof(ulong);
#else
/// <summary>The maximum natural alignment</summary>
public static readonly SizeT MAX_NATURAL_ALIGNMENT = sizeof(uint);
#endif
[StructLayout(LayoutKind.Sequential)]
private struct AlignedStruct<T> where T : struct
{
private readonly byte b;
public readonly T type;
}
/// <summary>Returns the alignment in bytes of the specified type as a value of type <see cref="SizeT"/>.</summary>
/// <typeparam name="T">The type for which to get the alignment.</typeparam>
/// <returns>The alignment in bytes of the specified type.</returns>
public static SizeT TYPE_ALIGNMENT<T>() where T : struct => Marshal.OffsetOf(typeof(AlignedStruct<T>), "type").ToInt64();
/// <summary>Returns the alignment in bytes of padding as a value of type <see cref="SizeT"/>.</summary>
/// <param name="length">The padding length.</param>
/// <returns>The alignment in bytes.</returns>
public static SizeT WSA_CMSGDATA_ALIGN(SizeT length) => (length + MAX_NATURAL_ALIGNMENT-1) & (~(MAX_NATURAL_ALIGNMENT-1));
/// <summary>Returns the alignment in bytes of WSACMSGHDR with padding as a value of type <see cref="SizeT"/>.</summary>
/// <param name="length">The padding length.</param>
/// <returns>The alignment in bytes.</returns>
public static SizeT WSA_CMSGHDR_ALIGN(SizeT length) =>
(length + TYPE_ALIGNMENT<WSACMSGHDR>()-1) & (~(TYPE_ALIGNMENT<WSACMSGHDR>()-1));
/// <summary>
/// Returns a pointer to the first byte of data (what is referred to as the cmsg_data member though it is not defined in the structure).
/// </summary>
/// <param name="cmsg">The WSACMSGHDR instance.</param>
/// <returns>The pointer.</returns>
public static unsafe byte* WSA_CMSG_DATA(WSACMSGHDR* cmsg) => (byte*)cmsg + WSA_CMSGDATA_ALIGN(Marshal.SizeOf(typeof(WSACMSGHDR)));
/// <summary>
/// Returns the first ancillary data object, or a null if there is no ancillary data in the control buffer of the WSAMSG structure.
/// </summary>
/// <param name="msg">The message.</param>
/// <returns>The first ancillary data object, or a null.</returns>
public static unsafe WSACMSGHDR* WSA_CMSG_FIRSTHDR(in WSAMSG msg) =>
(msg.Control.len >= Marshal.SizeOf(typeof(WSACMSGHDR))) ? (WSACMSGHDR*)msg.Control.buf : default;
/// <summary>Returns the value to store in cmsg_len given the amount of data.</summary>
/// <param name="length">The length.</param>
/// <returns>The data length.</returns>
public static SizeT WSA_CMSG_LEN(SizeT length) => WSA_CMSGDATA_ALIGN(Marshal.SizeOf(typeof(WSACMSGHDR))) + length;
/// <summary>Returns the next ancillary data object, or a null if there are no more data objects.</summary>
/// <param name="msg">The message.</param>
/// <param name="cmsg">The message header.</param>
/// <returns>The next header.</returns>
public static unsafe WSACMSGHDR* WSA_CMSG_NXTHDR(in WSAMSG msg, WSACMSGHDR* cmsg)
{
if (cmsg is null)
return WSA_CMSG_FIRSTHDR(msg);
unsafe
{
var len = (byte*)cmsg + WSA_CMSGHDR_ALIGN(cmsg->cmsg_len) + Marshal.SizeOf(typeof(WSACMSGHDR));
return len > (byte*)msg.Control.buf + msg.Control.len ? null : (WSACMSGHDR*)((byte*)cmsg + WSA_CMSGHDR_ALIGN(cmsg->cmsg_len));
}
}
/// <summary>Returns total size of an ancillary data object given the amount of data. Used to allocate the correct amount of space.</summary>
/// <param name="length">The length.</param>
/// <returns>Total size</returns>
public static SizeT WSA_CMSG_SPACE(SizeT length) => WSA_CMSGDATA_ALIGN(Marshal.SizeOf(typeof(WSACMSGHDR)) + WSA_CMSGHDR_ALIGN(length));
/// <summary>
/// The addrinfoex2 structure is used by the GetAddrInfoEx function to hold host address information when both a canonical name and
/// a fully qualified domain name have been requested.
/// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-addrinfoex2w typedef struct addrinfoex2W { int ai_flags; int
// ai_family; int ai_socktype; int ai_protocol; size_t ai_addrlen; PWSTR ai_canonname; struct sockaddr *ai_addr; void *ai_blob;
// size_t ai_bloblen; LPGUID ai_provider; struct addrinfoex2W *ai_next; int ai_version; PWSTR ai_fqdn; } ADDRINFOEX2W,
// *PADDRINFOEX2W, *LPADDRINFOEX2W;
[PInvokeData("ws2def.h", MSDNShortId = "9CB33347-A838-473D-B5CD-1149D6632CF2")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ADDRINFOEX2W
{
/// <summary>
/// <para>Flags that indicate options used in the GetAddrInfoEx function.</para>
/// <para>
/// Supported values for the <c>ai_flags</c> member are defined in the Winsock2.h include file and can be a combination of the
/// following options.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>AI_PASSIVE 0x01</term>
/// <term>The socket address will be used in a call to the bindfunction.</term>
/// </item>
/// <item>
/// <term>AI_CANONNAME 0x02</term>
/// <term>The canonical name is returned in the first ai_canonname member.</term>
/// </item>
/// <item>
/// <term>AI_NUMERICHOST 0x04</term>
/// <term>The nodename parameter passed to the GetAddrInfoEx function must be a numeric string.</term>
/// </item>
/// <item>
/// <term>AI_ALL 0x0100</term>
/// <term>
/// If this bit is set, a request is made for IPv6 addresses and IPv4 addresses with AI_V4MAPPED. This option is supported on
/// Windows Vista and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_ADDRCONFIG 0x0400</term>
/// <term>
/// The GetAddrInfoEx will resolve only if a global address is configured. The IPv6 and IPv4 loopback address is not considered
/// a valid global address. This option is supported on Windows Vista and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_V4MAPPED 0x0800</term>
/// <term>
/// If the GetAddrInfoEx request for an IPv6 addresses fails, a name service request is made for IPv4 addresses and these
/// addresses are converted to IPv4-mapped IPv6 address format. This option is supported on Windows Vista and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_NON_AUTHORITATIVE 0x04000</term>
/// <term>
/// The address information is from non-authoritative results. When this option is set in the pHints parameter of GetAddrInfoEx,
/// the NS_EMAIL namespace provider returns both authoritative and non-authoritative results. If this option is not set, then
/// only authoritative results are returned. This option is only supported on Windows Vista and later for the NS_EMAIL namespace.
/// </term>
/// </item>
/// <item>
/// <term>AI_SECURE 0x08000</term>
/// <term>
/// The address information is from a secure channel. If the AI_SECURE bit is set, the NS_EMAIL namespace provider will return
/// results that were obtained with enhanced security to minimize possible spoofing. When this option is set in the pHints
/// parameter of GetAddrInfoEx, the NS_EMAIL namespace provider returns only results that were obtained with enhanced security
/// to minimize possible spoofing. This option is only supported on Windows Vista and later for the NS_EMAIL namespace.
/// </term>
/// </item>
/// <item>
/// <term>AI_RETURN_PREFERRED_NAMES 0x010000</term>
/// <term>
/// The address information is for a preferred names for publication with a specific namespace. When this option is set in the
/// pHints parameter of GetAddrInfoEx, no name should be provided in the pName parameter and the NS_EMAIL namespace provider
/// will return preferred names for publication. This option is only supported on Windows Vista and later for the NS_EMAIL namespace.
/// </term>
/// </item>
/// <item>
/// <term>AI_FQDN 0x00020000</term>
/// <term>
/// The fully qualified domain name is returned in the first ai_fqdn member. When this option is set in the pHints parameter of
/// GetAddrInfoEx and a flat name (single label) is specified in the pName parameter, the fully qualified domain name that the
/// name eventually resolved to will be returned. This option is supported on Windows 7, Windows Server 2008 R2, and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_FILESERVER 0x00040000</term>
/// <term>
/// A hint to the namespace provider that the hostname being queried is being used in a file share scenario. The namespace
/// provider may ignore this hint. This option is supported on Windows 7, Windows Server 2008 R2, and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_DISABLE_IDN_ENCODING 0x00080000</term>
/// <term>
/// Disable the automatic International Domain Name encoding using Punycode in the name resolution functions called by the
/// GetAddrInfoEx function. This option is supported on Windows 8, Windows Server 2012, and later.
/// </term>
/// </item>
/// </list>
/// </summary>
public ADDRINFO_FLAGS ai_flags;
private uint _ai_family;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>The address family. Possible values for the address family are defined in the Winsock2.h include file.</para>
/// <para>
/// On the Windows SDK released for Windows Vista and later,, the organization of header files has changed and the possible
/// values for the address family are defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically
/// included in Winsock2.h, and should never be used directly.
/// </para>
/// <para>
/// The values currently supported are <c>AF_INET</c> or <c>AF_INET6</c>, which are the Internet address family formats for IPv4
/// and IPv6. Other options for address family ( <c>AF_NETBIOS</c> for use with NetBIOS, for example) are supported if a Windows
/// Sockets service provider for the address family is installed. Note that the values for the AF_ address family and PF_
/// protocol family constants are identical (for example, <c>AF_UNSPEC</c> and <c>PF_UNSPEC</c>), so either constant can be used.
/// </para>
/// <para>The table below lists common values for the address family although many other values are possible.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>AF_UNSPEC 0</term>
/// <term>The address family is unspecified.</term>
/// </item>
/// <item>
/// <term>AF_INET 2</term>
/// <term>The Internet Protocol version 4 (IPv4) address family.</term>
/// </item>
/// <item>
/// <term>AF_NETBIOS 17</term>
/// <term>The NetBIOS address family. This address family is only supported if a Windows Sockets provider for NetBIOS is installed.</term>
/// </item>
/// <item>
/// <term>AF_INET6 23</term>
/// <term>The Internet Protocol version 6 (IPv6) address family.</term>
/// </item>
/// <item>
/// <term>AF_IRDA 26</term>
/// <term>
/// The Infrared Data Association (IrDA) address family. This address family is only supported if the computer has an infrared
/// port and driver installed.
/// </term>
/// </item>
/// <item>
/// <term>AF_BTH 32</term>
/// <term>
/// The Bluetooth address family. This address family is only supported if a Bluetooth adapter is installed on Windows Server
/// 2003 or later.
/// </term>
/// </item>
/// </list>
/// </summary>
public ADDRESS_FAMILY ai_family { get => (ADDRESS_FAMILY)_ai_family; set => _ai_family = (ushort)value; }
/// <summary>
/// <para>The socket type. Possible values for the socket type are defined in the Winsock2.h include file.</para>
/// <para>The following table lists the possible values for the socket type supported for Windows Sockets 2:</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>SOCK_STREAM 1</term>
/// <term>
/// Provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism. Uses the
/// Transmission Control Protocol (TCP) for the Internet address family (AF_INET or AF_INET6). If the ai_family member is
/// AF_IRDA, then SOCK_STREAM is the only supported socket type.
/// </term>
/// </item>
/// <item>
/// <term>SOCK_DGRAM 2</term>
/// <term>
/// Supports datagrams, which are connectionless, unreliable buffers of a fixed (typically small) maximum length. Uses the User
/// Datagram Protocol (UDP) for the Internet address family (AF_INET or AF_INET6).
/// </term>
/// </item>
/// <item>
/// <term>SOCK_RAW 3</term>
/// <term>
/// Provides a raw socket that allows an application to manipulate the next upper-layer protocol header. To manipulate the IPv4
/// header, the IP_HDRINCL socket option must be set on the socket. To manipulate the IPv6 header, the IPV6_HDRINCL socket
/// option must be set on the socket.
/// </term>
/// </item>
/// <item>
/// <term>SOCK_RDM 4</term>
/// <term>
/// Provides a reliable message datagram. An example of this type is the Pragmatic General Multicast (PGM) multicast protocol
/// implementation in Windows, often referred to as reliable multicast programming.
/// </term>
/// </item>
/// <item>
/// <term>SOCK_SEQPACKET 5</term>
/// <term>Provides a pseudo-stream packet based on datagrams.</term>
/// </item>
/// </list>
/// <para>
/// In Windows Sockets 2, new socket types were introduced. An application can dynamically discover the attributes of each
/// available transport protocol through the WSAEnumProtocols function. So an application can determine the possible socket type
/// and protocol options for an address family and use this information when specifying this parameter. Socket type definitions
/// in the Winsock2.h and Ws2def.h header files will be periodically updated as new socket types, address families, and
/// protocols are defined.
/// </para>
/// <para>In Windows Sockets 1.1, the only possible socket types are <c>SOCK_DATAGRAM</c> and <c>SOCK_STREAM</c>.</para>
/// </summary>
public SOCK ai_socktype;
/// <summary>
/// <para>
/// The protocol type. The possible options are specific to the address family and socket type specified. Possible values for
/// the <c>ai_protocol</c> are defined in Winsock2.h and the Wsrm.h header files.
/// </para>
/// <para>
/// On the Windows SDK released for Windows Vista and later,, the organization of header files has changed and this member can
/// be one of the values from the <c>IPPROTO</c> enumeration type defined in the Ws2def.h header file. Note that the Ws2def.h
/// header file is automatically included in Winsock2.h, and should never be used directly.
/// </para>
/// <para>
/// If a value of 0 is specified for <c>ai_protocol</c>, the caller does not wish to specify a protocol and the service provider
/// will choose the <c>ai_protocol</c> to use. For protocols other than IPv4 and IPv6, set <c>ai_protocol</c> to zero.
/// </para>
/// <para>The following table lists common values for the <c>ai_protocol</c> member although many other values are possible.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>IPPROTO_TCP 6</term>
/// <term>
/// The Transmission Control Protocol (TCP). This is a possible value when the ai_family member is AF_INET or AF_INET6 and the
/// ai_socktype member is SOCK_STREAM.
/// </term>
/// </item>
/// <item>
/// <term>IPPROTO_UDP 17</term>
/// <term>
/// The User Datagram Protocol (UDP). This is a possible value when the ai_family member is AF_INET or AF_INET6 and the type
/// parameter is SOCK_DGRAM.
/// </term>
/// </item>
/// <item>
/// <term>IPPROTO_RM 113</term>
/// <term>
/// The PGM protocol for reliable multicast. This is a possible value when the ai_family member is AF_INET and the ai_socktype
/// member is SOCK_RDM. On the Windows SDK released for Windows Vista and later, this value is also called IPPROTO_PGM.
/// </term>
/// </item>
/// </list>
/// <para>If the <c>ai_family</c> member is <c>AF_IRDA</c>, then the <c>ai_protocol</c> must be 0.</para>
/// </summary>
public IPPROTO ai_protocol;
/// <summary>The length, in bytes, of the buffer pointed to by the <c>ai_addr</c> member.</summary>
public SizeT ai_addrlen;
/// <summary>The canonical name for the host.</summary>
public StrPtrUni ai_canonname;
/// <summary>
/// A pointer to a sockaddr structure. The <c>ai_addr</c> member in each returned <c>addrinfoex2</c> structure points to a
/// filled-in socket address structure. The length, in bytes, of each returned <c>addrinfoex2</c> structure is specified in the
/// <c>ai_addrlen</c> member.
/// </summary>
public IntPtr ai_addr;
/// <summary>
/// A pointer to data that is used to return provider-specific namespace information that is associated with the name beyond a
/// list of addresses. The length, in bytes, of the buffer pointed to by <c>ai_blob</c> must be specified in the
/// <c>ai_bloblen</c> member.
/// </summary>
public IntPtr ai_blob;
/// <summary>The length, in bytes, of the <c>ai_blob</c> member.</summary>
public SizeT ai_bloblen;
/// <summary>A pointer to the GUID of a specific namespace provider.</summary>
public GuidPtr ai_provider;
/// <summary>
/// A pointer to the next structure in a linked list. This parameter is set to <c>NULL</c> in the last <c>addrinfoex2</c>
/// structure of a linked list.
/// </summary>
public IntPtr ai_next;
/// <summary>The version number of this structure. The value currently used for this version of the structure is 2.</summary>
public int ai_version;
/// <summary>The fully qualified domain name for the host.</summary>
public StrPtrUni ai_fqdn;
/// <summary>
/// <para>Type: <c>struct sockaddr*</c></para>
/// <para>
/// A pointer to a sockaddr structure. The <c>ai_addr</c> member in each returned ADDRINFOW structure points to a filled-in
/// socket address structure. The length, in bytes, of each returned <c>ADDRINFOW</c> structure is specified in the
/// <c>ai_addrlen</c> member.
/// </para>
/// </summary>
public SOCKADDR addr => new(ai_addr, false, ai_addrlen);
/// <inheritdoc/>
public override string ToString() => $"{ai_fqdn}::{ai_canonname}:{ai_flags},{ai_family},{ai_socktype},{ai_protocol},{addr}";
}
/// <summary>The <c>addrinfoex</c> structure is used by the GetAddrInfoEx function to hold host address information.</summary>
/// <remarks>
/// <para>
/// The <c>addrinfoex</c> structure is used by the GetAddrInfoEx function to hold host address information. The <c>addrinfoex</c>
/// structure is an enhanced version of the addrinfo and addrinfoW structures. The extra structure members are for blob data and the
/// GUID for the namespace provider. The blob data is used to return additional provider-specific namespace information associated
/// with a name. The format of data in the <c>ai_blob</c> member is specific to a particular namespace provider. Currently, blob
/// data is used by the <c>NS_EMAIL</c> namespace provider to supply additional information.
/// </para>
/// <para>
/// The <c>addrinfoex</c> structure is an enhanced version of the addrinfo and addrinfoW structure used with GetAddrInfoEx function.
/// The <c>GetAddrInfoEx</c> function allows specifying the namespace provider to resolve the query. For use with the IPv6 and IPv4
/// protocol, name resolution can be by the Domain Name System (DNS), a local hosts file, an email provider (the <c>NS_EMAIL</c>
/// namespace), or by other naming mechanisms.
/// </para>
/// <para>
/// When UNICODE or _UNICODE is defined, <c>addrinfoex</c> is defined to <c>addrinfoexW</c>, the Unicode version of this structure.
/// The string parameters are defined to the <c>PWSTR</c> data type and the <c>addrinfoexW</c> structure is used.
/// </para>
/// <para>
/// When UNICODE or _UNICODE is not defined, <c>addrinfoex</c> is defined to <c>addrinfoexA</c>, the ANSI version of this structure.
/// The string parameters are of the <c>PCSTR</c> data type and the <c>addrinfoexA</c> structure is used.
/// </para>
/// <para>
/// Upon a successful call to GetAddrInfoEx, a linked list of <c>addrinfoex</c> structures is returned in the ppResult parameter
/// passed to the <c>GetAddrInfoEx</c> function. The list can be processed by following the pointer provided in the <c>ai_next</c>
/// member of each returned <c>addrinfoex</c> structure until a <c>NULL</c> pointer is encountered. In each returned
/// <c>addrinfoex</c> structure, the <c>ai_family</c>, <c>ai_socktype</c>, and <c>ai_protocol</c> members correspond to respective
/// arguments in a socket or WSASocket function call. Also, the <c>ai_addr</c> member in each returned <c>addrinfoex</c> structure
/// points to a filled-in socket address structure, the length of which is specified in its <c>ai_addrlen</c> member.
/// </para>
/// <para>Examples</para>
/// <para>The following example demonstrates the use of the <c>addrinfoex</c> structure.</para>
/// <para>
/// <c>Note</c> Ensure that the development environment targets the newest version of Ws2tcpip.h which includes structure and
/// function definitions for <c>ADDRINFOEX</c> and GetAddrInfoEx, respectively.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-addrinfoexa typedef struct addrinfoexA { int ai_flags; int
// ai_family; int ai_socktype; int ai_protocol; size_t ai_addrlen; char *ai_canonname; struct sockaddr *ai_addr; void *ai_blob;
// size_t ai_bloblen; LPGUID ai_provider; struct addrinfoexA *ai_next; } ADDRINFOEXA, *PADDRINFOEXA, *LPADDRINFOEXA;
[PInvokeData("ws2def.h", MSDNShortId = "1077e03d-a1a4-45ab-a5d2-29a67e03f5df")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct ADDRINFOEXW
{
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Flags that indicate options used in the GetAddrInfoEx function.</para>
/// <para>
/// Supported values for the <c>ai_flags</c> member are defined in the Winsock2.h include file and can be a combination of the
/// following options.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>AI_PASSIVE 0x01</term>
/// <term>The socket address will be used in a call to the bindfunction.</term>
/// </item>
/// <item>
/// <term>AI_CANONNAME 0x02</term>
/// <term>
/// The canonical name is returned in the first ai_canonname member. When both the AI_CANONNAME and AI_FQDN bits are set, an
/// addrinfoex2 structure is returned not the addrinfoex structure.
/// </term>
/// </item>
/// <item>
/// <term>AI_NUMERICHOST 0x04</term>
/// <term>The nodename parameter passed to the GetAddrInfoEx function must be a numeric string.</term>
/// </item>
/// <item>
/// <term>AI_ALL 0x0100</term>
/// <term>
/// If this bit is set, a request is made for IPv6 addresses and IPv4 addresses with AI_V4MAPPED. This option is supported on
/// Windows Vista and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_ADDRCONFIG 0x0400</term>
/// <term>
/// The GetAddrInfoEx will resolve only if a global address is configured. The IPv6 and IPv4 loopback address is not considered
/// a valid global address. This option is only supported on Windows Vista and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_V4MAPPED 0x0800</term>
/// <term>
/// If the GetAddrInfoEx request for an IPv6 addresses fails, a name service request is made for IPv4 addresses and these
/// addresses are converted to IPv4-mapped IPv6 address format. This option is supported on Windows Vista and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_NON_AUTHORITATIVE 0x04000</term>
/// <term>
/// The address information is from non-authoritative results. When this option is set in the pHints parameter of GetAddrInfoEx,
/// the NS_EMAIL namespace provider returns both authoritative and non-authoritative results. If this option is not set, then
/// only authoritative results are returned. In the ppResults parameter returned by GetAddrInfoEx, this flag is set in the
/// ai_flags member of the addrinfoex structure for non-authoritative results. This option is only supported on Windows Vista
/// and later for the NS_EMAIL namespace.
/// </term>
/// </item>
/// <item>
/// <term>AI_SECURE 0x08000</term>
/// <term>
/// The address information is from a secure channel. If the AI_SECURE bit is set, the NS_EMAIL namespace provider will return
/// results that were obtained with enhanced security to minimize possible spoofing. When this option is set in the pHints
/// parameter of GetAddrInfoEx, the NS_EMAIL namespace provider returns only results that were obtained with enhanced security
/// to minimize possible spoofing. In the ppResults parameter returned by GetAddrInfoEx, this flag is set in the ai_flags member
/// of the addrinfoex structure for results returned with enhanced security to minimize possible spoofing. This option is only
/// supported on Windows Vista and later for the NS_EMAIL namespace.
/// </term>
/// </item>
/// <item>
/// <term>AI_RETURN_PREFERRED_NAMES 0x010000</term>
/// <term>
/// The address information is for a preferred names for publication with a specific namespace. When this option is set in the
/// pHints parameter of GetAddrInfoEx, no name should be provided in the pName parameter and the NS_EMAIL namespace provider
/// will return preferred names for publication. In the ppResults parameter returned by GetAddrInfoEx, this flag is set in the
/// ai_flags member of the addrinfoex structure for results returned for preferred names for publication. This option is only
/// supported on Windows Vista and later for the NS_EMAIL namespace.
/// </term>
/// </item>
/// <item>
/// <term>AI_FQDN 0x00020000</term>
/// <term>
/// The fully qualified domain name is returned in the first ai_canonicalname member. When this option is set in the pHints
/// parameter of GetAddrInfoEx and a flat name (single label) is specified in the pName parameter, the fully qualified domain
/// name that the name eventually resolved to will be returned. When both the AI_CANONNAME and AI_FQDN bits are set, an
/// addrinfoex2 structure is returned not the addrinfoex structure. This option is supported on Windows 7, Windows Server 2008
/// R2, and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_FILESERVER 0x00040000</term>
/// <term>
/// A hint to the namespace provider that the hostname being queried is being used in a file share scenario. The namespace
/// provider may ignore this hint. This option is supported on Windows 7, Windows Server 2008 R2, and later.
/// </term>
/// </item>
/// <item>
/// <term>AI_DISABLE_IDN_ENCODING 0x00080000</term>
/// <term>
/// Disable the automatic International Domain Name encoding using Punycode in the name resolution functions called by the
/// GetAddrInfoEx function. This option is supported on Windows 8, Windows Server 2012, and later.
/// </term>
/// </item>
/// </list>
/// </summary>
public ADDRINFO_FLAGS ai_flags;
private uint _ai_family;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>The address family. Possible values for the address family are defined in the Winsock2.h include file.</para>
/// <para>
/// On the Windows SDK released for Windows Vista and later,, the organization of header files has changed and the possible
/// values for the address family are defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically
/// included in Winsock2.h, and should never be used directly.
/// </para>
/// <para>
/// The values currently supported are <c>AF_INET</c> or <c>AF_INET6</c>, which are the Internet address family formats for IPv4
/// and IPv6. Other options for address family ( <c>AF_NETBIOS</c> for use with NetBIOS, for example) are supported if a Windows
/// Sockets service provider for the address family is installed. Note that the values for the AF_ address family and PF_
/// protocol family constants are identical (for example, <c>AF_UNSPEC</c> and <c>PF_UNSPEC</c>), so either constant can be used.
/// </para>
/// <para>The table below lists common values for the address family although many other values are possible.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>AF_UNSPEC 0</term>
/// <term>The address family is unspecified.</term>
/// </item>
/// <item>
/// <term>AF_INET 2</term>
/// <term>The Internet Protocol version 4 (IPv4) address family.</term>
/// </item>
/// <item>
/// <term>AF_NETBIOS 17</term>
/// <term>The NetBIOS address family. This address family is only supported if a Windows Sockets provider for NetBIOS is installed.</term>
/// </item>
/// <item>
/// <term>AF_INET6 23</term>
/// <term>The Internet Protocol version 6 (IPv6) address family.</term>
/// </item>
/// <item>
/// <term>AF_IRDA 26</term>
/// <term>
/// The Infrared Data Association (IrDA) address family. This address family is only supported if the computer has an infrared
/// port and driver installed.
/// </term>
/// </item>
/// <item>
/// <term>AF_BTH 32</term>
/// <term>
/// The Bluetooth address family. This address family is only supported if a Bluetooth adapter is installed on Windows Server
/// 2003 or later.
/// </term>
/// </item>
/// </list>
/// </summary>
public ADDRESS_FAMILY ai_family { get => (ADDRESS_FAMILY)_ai_family; set => _ai_family = (ushort)value; }
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>The socket type. Possible values for the socket type are defined in the Winsock2.h include file.</para>
/// <para>The following table lists the possible values for the socket type supported for Windows Sockets 2:</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>SOCK_STREAM 1</term>
/// <term>
/// Provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism. Uses the
/// Transmission Control Protocol (TCP) for the Internet address family (AF_INET or AF_INET6). If the ai_family member is
/// AF_IRDA, then SOCK_STREAM is the only supported socket type.
/// </term>
/// </item>
/// <item>
/// <term>SOCK_DGRAM 2</term>
/// <term>
/// Supports datagrams, which are connectionless, unreliable buffers of a fixed (typically small) maximum length. Uses the User
/// Datagram Protocol (UDP) for the Internet address family (AF_INET or AF_INET6).
/// </term>
/// </item>
/// <item>
/// <term>SOCK_RAW 3</term>
/// <term>
/// Provides a raw socket that allows an application to manipulate the next upper-layer protocol header. To manipulate the IPv4
/// header, the IP_HDRINCL socket option must be set on the socket. To manipulate the IPv6 header, the IPV6_HDRINCL socket
/// option must be set on the socket.
/// </term>
/// </item>
/// <item>
/// <term>SOCK_RDM 4</term>
/// <term>
/// Provides a reliable message datagram. An example of this type is the Pragmatic General Multicast (PGM) multicast protocol
/// implementation in Windows, often referred to as reliable multicast programming.
/// </term>
/// </item>
/// <item>
/// <term>SOCK_SEQPACKET 5</term>
/// <term>Provides a pseudo-stream packet based on datagrams.</term>
/// </item>
/// </list>
/// <para>
/// In Windows Sockets 2, new socket types were introduced. An application can dynamically discover the attributes of each
/// available transport protocol through the WSAEnumProtocols function. So an application can determine the possible socket type
/// and protocol options for an address family and use this information when specifying this parameter. Socket type definitions
/// in the Winsock2.h and Ws2def.h header files will be periodically updated as new socket types, address families, and
/// protocols are defined.
/// </para>
/// <para>In Windows Sockets 1.1, the only possible socket types are <c>SOCK_DATAGRAM</c> and <c>SOCK_STREAM</c>.</para>
/// </summary>
public SOCK ai_socktype;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// The protocol type. The possible options are specific to the address family and socket type specified. Possible values for
/// the <c>ai_protocol</c> are defined in Winsock2.h and the Wsrm.h header files.
/// </para>
/// <para>
/// On the Windows SDK released for Windows Vista and later,, the organization of header files has changed and this member can
/// be one of the values from the <c>IPPROTO</c> enumeration type defined in the Ws2def.h header file. Note that the Ws2def.h
/// header file is automatically included in Winsock2.h, and should never be used directly.
/// </para>
/// <para>
/// If a value of 0 is specified for <c>ai_protocol</c>, the caller does not wish to specify a protocol and the service provider