Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SocketProtocolSupportPal.cs
Go to the documentation of this file.
1
using
System.Net.Internals
;
2
using
System.Net.Sockets
;
3
using
System.Runtime.CompilerServices
;
4
using
System.Runtime.InteropServices
;
5
6
namespace
System.Net
;
7
8
internal
static
class
SocketProtocolSupportPal
9
{
10
[CompilerGenerated]
11
private
static
readonly
bool
_003COSSupportsIPv4_003Ek__BackingField
=
IsSupported
(
AddressFamily
.InterNetwork);
12
13
[CompilerGenerated]
14
private
static
readonly
bool
_003COSSupportsUnixDomainSockets_003Ek__BackingField
=
IsSupported
(
AddressFamily
.Unix);
15
16
public
static
bool
OSSupportsIPv6
{
get
; } =
IsSupported
(
AddressFamily
.InterNetworkV6) && !
IsIPv6Disabled
();
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,
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
}
System.AppContext.TryGetSwitch
static bool TryGetSwitch(string switchName, out bool isEnabled)
Definition
AppContext.cs:74
System.AppContext
Definition
AppContext.cs:14
System.Environment.GetEnvironmentVariable
static ? string GetEnvironmentVariable(string variable)
Definition
Environment.cs:441
System.Environment
Definition
Environment.cs:15
System.Net.SocketProtocolSupportPal._003COSSupportsIPv4_003Ek__BackingField
static readonly bool _003COSSupportsIPv4_003Ek__BackingField
Definition
SocketProtocolSupportPal.cs:11
System.Net.SocketProtocolSupportPal.IsIPv6Disabled
static bool IsIPv6Disabled()
Definition
SocketProtocolSupportPal.cs:19
System.Net.SocketProtocolSupportPal._003COSSupportsUnixDomainSockets_003Ek__BackingField
static readonly bool _003COSSupportsUnixDomainSockets_003Ek__BackingField
Definition
SocketProtocolSupportPal.cs:14
System.Net.SocketProtocolSupportPal.IsSupported
static bool IsSupported(AddressFamily af)
Definition
SocketProtocolSupportPal.cs:37
System.Net.SocketProtocolSupportPal.OSSupportsIPv6
static bool OSSupportsIPv6
Definition
SocketProtocolSupportPal.cs:16
System.Net.SocketProtocolSupportPal
Definition
SocketProtocolSupportPal.cs:9
System.Runtime.InteropServices.Marshal.GetLastWin32Error
static int GetLastWin32Error()
Definition
Marshal.cs:1567
System.Runtime.InteropServices.Marshal
Definition
Marshal.cs:14
System.Net.Internals.SocketType
SocketType
Definition
SocketType.cs:4
System.Net.Internals
Definition
SocketExceptionFactory.cs:3
System.Net.Sockets.AddressFamily
AddressFamily
Definition
AddressFamily.cs:4
System.Net.Sockets
Definition
AddressInfoHints.cs:1
System.Net
Definition
HttpClientJsonExtensions.cs:8
System.Runtime.CompilerServices
Definition
NullablePublicOnlyAttribute.cs:3
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.StringComparison
StringComparison
Definition
StringComparison.cs:4
System.IntPtr.Zero
static readonly IntPtr Zero
Definition
IntPtr.cs:18
System.IntPtr
Definition
IntPtr.cs:14
source
System.Net.NameResolution
System.Net
SocketProtocolSupportPal.cs
Generated by
1.10.0