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.Sockets
;
2
using
System.Runtime.InteropServices
;
3
4
namespace
System.Net
;
5
6
internal
static
class
SocketProtocolSupportPal
7
{
8
public
static
bool
OSSupportsIPv6
{
get
; } =
IsSupported
(
AddressFamily
.InterNetworkV6) && !
IsIPv6Disabled
();
9
10
11
public
static
bool
OSSupportsIPv4
{
get
; } =
IsSupported
(
AddressFamily
.InterNetwork);
12
13
14
public
static
bool
OSSupportsUnixDomainSockets
{
get
; } =
IsSupported
(
AddressFamily
.Unix);
15
16
17
private
static
bool
IsIPv6Disabled
()
18
{
19
if
(
AppContext
.
TryGetSwitch
(
"System.Net.DisableIPv6"
, out var isEnabled))
20
{
21
return
isEnabled;
22
}
23
string
environmentVariable =
Environment
.
GetEnvironmentVariable
(
"DOTNET_SYSTEM_NET_DISABLEIPV6"
);
24
if
(environmentVariable !=
null
)
25
{
26
if
(!(environmentVariable ==
"1"
))
27
{
28
return
environmentVariable.Equals(
"true"
,
StringComparison
.OrdinalIgnoreCase);
29
}
30
return
true
;
31
}
32
return
false
;
33
}
34
35
private
static
bool
IsSupported
(
AddressFamily
af)
36
{
37
global::Interop.Winsock.EnsureInitialized();
38
IntPtr
intPtr = (
IntPtr
)(-1);
39
IntPtr
intPtr2 = intPtr;
40
try
41
{
42
intPtr2 = global::Interop.Winsock.WSASocketW(af,
SocketType
.Stream, 0,
IntPtr
.
Zero
, 0, 128);
43
return
intPtr2 != intPtr ||
Marshal
.
GetLastWin32Error
() != 10047;
44
}
45
finally
46
{
47
if
(intPtr2 != intPtr)
48
{
49
global::Interop.Winsock.closesocket(intPtr2);
50
}
51
}
52
}
53
}
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.OSSupportsUnixDomainSockets
static bool OSSupportsUnixDomainSockets
Definition
SocketProtocolSupportPal.cs:14
System.Net.SocketProtocolSupportPal.IsIPv6Disabled
static bool IsIPv6Disabled()
Definition
SocketProtocolSupportPal.cs:19
System.Net.SocketProtocolSupportPal.OSSupportsIPv4
static bool OSSupportsIPv4
Definition
SocketProtocolSupportPal.cs:16
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.Sockets.AddressFamily
AddressFamily
Definition
AddressFamily.cs:4
System.Net.Sockets.SocketType
SocketType
Definition
SocketType.cs:4
System.Net.Sockets
Definition
AddressInfoHints.cs:1
System.Net
Definition
HttpClientJsonExtensions.cs:8
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.Sockets
System.Net
SocketProtocolSupportPal.cs
Generated by
1.10.0