Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SocketProtocolSupportPal.cs
Go to the documentation of this file.
5
6namespace System.Net;
7
8internal static class SocketProtocolSupportPal
9{
10 [CompilerGenerated]
12
13 public static bool OSSupportsIPv6 { get; } = IsSupported(AddressFamily.InterNetworkV6) && !IsIPv6Disabled();
14
15
16 public static bool OSSupportsIPv4 { get; } = IsSupported(AddressFamily.InterNetwork);
17
18
19 private static bool IsIPv6Disabled()
20 {
21 if (AppContext.TryGetSwitch("System.Net.DisableIPv6", out var isEnabled))
22 {
23 return isEnabled;
24 }
25 string environmentVariable = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_NET_DISABLEIPV6");
26 if (environmentVariable != null)
27 {
28 if (!(environmentVariable == "1"))
29 {
30 return environmentVariable.Equals("true", StringComparison.OrdinalIgnoreCase);
31 }
32 return true;
33 }
34 return false;
35 }
36
37 private static bool IsSupported(AddressFamily af)
38 {
39 global::Interop.Winsock.EnsureInitialized();
40 IntPtr intPtr = (IntPtr)(-1);
41 IntPtr intPtr2 = intPtr;
42 try
43 {
44 intPtr2 = global::Interop.Winsock.WSASocketW(af, System.Net.Internals.SocketType.Stream, 0, IntPtr.Zero, 0, 128);
45 return intPtr2 != intPtr || Marshal.GetLastWin32Error() != 10047;
46 }
47 finally
48 {
49 if (intPtr2 != intPtr)
50 {
51 global::Interop.Winsock.closesocket(intPtr2);
52 }
53 }
54 }
55}
static bool TryGetSwitch(string switchName, out bool isEnabled)
Definition AppContext.cs:74
static ? string GetEnvironmentVariable(string variable)
static readonly bool _003COSSupportsUnixDomainSockets_003Ek__BackingField
static bool IsSupported(AddressFamily af)
static readonly IntPtr Zero
Definition IntPtr.cs:18