1006 references to SocketError
ClientSample (9)
Tcp\SocketAwaitable.cs (3)
24
private
SocketError
_error;
40
if (_error !=
SocketError
.Success)
62
public void Complete(int bytesTransferred,
SocketError
socketError)
Tcp\TcpConnection.cs (6)
116
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.ConnectionReset)
120
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.OperationAborted ||
121
ex.SocketErrorCode ==
SocketError
.ConnectionAborted ||
122
ex.SocketErrorCode ==
SocketError
.Interrupted ||
123
ex.SocketErrorCode ==
SocketError
.InvalidArgument)
191
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.OperationAborted)
dotnet-svcutil-lib (2)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\CoreClrSocketConnection.cs (2)
481
if (_asyncWriteEventArgs.SocketError ==
SocketError
.Success)
720
if (_asyncReadEventArgs.SocketError ==
SocketError
.Success)
HttpStress (1)
Program.cs (1)
597
if (e is HttpRequestException hre && hre.InnerException is SocketException se && se.SocketErrorCode ==
SocketError
.AddressAlreadyInUse)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (1)
Internal\QuicConnectionListener.cs (1)
134
catch (SocketException e) when (e.SocketErrorCode ==
SocketError
.AddressAlreadyInUse)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (21)
Internal\SocketAwaitableEventArgs.cs (3)
51
if (SocketError !=
SocketError
.Success)
59
protected static SocketException CreateException(
SocketError
e)
67
SocketError ==
SocketError
.Success ? ValueTaskSourceStatus.Succeeded :
Internal\SocketConnection.cs (8)
420
private static bool IsConnectionResetError(
SocketError
errorCode)
422
return errorCode ==
SocketError
.ConnectionReset ||
423
errorCode ==
SocketError
.Shutdown ||
424
(errorCode ==
SocketError
.ConnectionAborted && OperatingSystem.IsWindows());
427
private static bool IsConnectionAbortError(
SocketError
errorCode)
430
return errorCode ==
SocketError
.OperationAborted ||
431
errorCode ==
SocketError
.Interrupted ||
432
(errorCode ==
SocketError
.InvalidArgument && !OperatingSystem.IsWindows());
Internal\SocketReceiver.cs (4)
25
var
error = SocketError;
27
return error ==
SocketError
.Success
42
var
error = SocketError;
44
return error ==
SocketError
.Success
Internal\SocketSender.cs (4)
35
var
error = SocketError;
37
return error ==
SocketError
.Success
69
var
error = SocketError;
71
return error ==
SocketError
.Success
SocketConnectionListener.cs (2)
46
catch (SocketException e) when (e.SocketErrorCode ==
SocketError
.AddressAlreadyInUse)
82
catch (SocketException e) when (e.SocketErrorCode ==
SocketError
.OperationAborted)
Microsoft.Extensions.Diagnostics.ExceptionSummarization (5)
HttpExceptionSummaryProvider.cs (5)
25
private static readonly FrozenDictionary<
SocketError
, int> _socketErrorMap;
37
var socketErrors = new Dictionary<
SocketError
, int>();
42
foreach (var v in Enum.GetValues(typeof(
SocketError
)))
44
var
socketError = (
SocketError
)v!;
Microsoft.Extensions.Diagnostics.Probes.Tests (1)
TcpEndpointProbesServiceTests.cs (1)
109
if (e.SocketErrorCode ==
SocketError
.ConnectionRefused)
netstandard (1)
netstandard.cs (1)
1271
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.
SocketError
))]
Sockets.BindTests (4)
src\Servers\Kestrel\shared\test\TransportTestHelpers\HostNameIsReachableAttribute.cs (2)
48
ex.SocketErrorCode ==
SocketError
.NetworkUnreachable
49
|| ex.SocketErrorCode ==
SocketError
.HostNotFound)
src\Servers\Kestrel\test\BindTests\AddressRegistrationTests.cs (2)
1231
return mre.Wait(5000) && socketArgs.SocketError ==
SocketError
.Success;
1236
return socketArgs.SocketError ==
SocketError
.Success;
Sockets.FunctionalTests (2)
src\Servers\Kestrel\shared\test\TransportTestHelpers\HostNameIsReachableAttribute.cs (2)
48
ex.SocketErrorCode ==
SocketError
.NetworkUnreachable
49
|| ex.SocketErrorCode ==
SocketError
.HostNotFound)
System (1)
src\libraries\shims\System\ref\System.cs (1)
761
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.
SocketError
))]
System.IO.Pipes (4)
System\IO\Pipes\NamedPipeClientStream.Unix.cs (3)
54
case
SocketError
.AddressAlreadyInUse:
55
case
SocketError
.AddressNotAvailable:
56
case
SocketError
.ConnectionRefused:
System\IO\Pipes\PipeStream.Unix.cs (1)
334
if (e.SocketErrorCode ==
SocketError
.Shutdown) // EPIPE
System.Net (1)
System.Net.cs (1)
42
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.
SocketError
))]
System.Net.Http (2)
System\Net\Http\SocketsHttpHandler\ConnectHelper.cs (2)
157
socketException.SocketErrorCode is
SocketError
.HostNotFound or
SocketError
.TryAgain)
System.Net.HttpListener (1)
System\Net\Managed\HttpEndPointListener.cs (1)
110
Socket? accepted = args.SocketError ==
SocketError
.Success ? args.AcceptSocket : null;
System.Net.NameResolution (23)
System\Net\Dns.cs (6)
399
SocketError
errorCode = NameResolutionPal.TryGetAddrInfo(hostName, justAddresses, addressFamily, out string? newHostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode);
401
if (errorCode !=
SocketError
.Success)
446
SocketError
errorCode;
451
if (errorCode !=
SocketError
.Success)
474
if (errorCode !=
SocketError
.Success)
740
private static SocketException CreateException(
SocketError
error, int nativeError) =>
System\Net\NameResolutionPal.Unix.cs (13)
27
private static
SocketError
GetSocketErrorForNativeError(int error)
32
return
SocketError
.Success;
34
return
SocketError
.TryAgain;
37
return
SocketError
.InvalidArgument;
39
return
SocketError
.NoRecovery;
41
return
SocketError
.AddressFamilyNotSupported;
43
return
SocketError
.HostNotFound;
48
return
SocketError
.SocketError;
51
return
SocketError
.SocketError;
130
public static unsafe
SocketError
TryGetAddrInfo(string name, bool justAddresses, AddressFamily addressFamily, out string? hostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode)
151
return
SocketError
.Success;
154
public static unsafe string? TryGetNameInfo(IPAddress addr, out
SocketError
socketError, out int nativeErrorCode)
189
return socketError ==
SocketError
.Success ? Marshal.PtrToStringUTF8((IntPtr)buffer) : null;
System\Net\NameResolutionTelemetry.cs (4)
147
SocketError
.HostNotFound => "host_not_found",
148
SocketError
.TryAgain => "try_again",
149
SocketError
.AddressFamilyNotSupported => "address_family_not_supported",
150
SocketError
.NoRecovery => "no_recovery",
System.Net.NetworkInformation (2)
src\libraries\Common\src\System\Net\NetworkInformation\NetworkInformationException.cs (1)
46
internal NetworkInformationException(
SocketError
socketError) : base((int)socketError)
System\Net\NetworkInformation\NetworkAddressChange.Unix.cs (1)
206
catch (SocketException se) when (se.SocketErrorCode ==
SocketError
.OperationAborted)
System.Net.Ping (102)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReceiveSocketError.cs (1)
13
internal static unsafe partial
SocketError
ReceiveSocketError(SafeHandle socket, MessageHeader* messageHeader);
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29
throw new SocketException((int)
SocketError
.AddressFamilyNotSupported);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
34
private static readonly Dictionary<Interop.Error,
SocketError
> s_nativeErrorToSocketError = new Dictionary<Interop.Error,
SocketError
>(NativeErrorToSocketErrorCount)
36
{ Interop.Error.EACCES,
SocketError
.AccessDenied },
37
{ Interop.Error.EADDRINUSE,
SocketError
.AddressAlreadyInUse },
38
{ Interop.Error.EADDRNOTAVAIL,
SocketError
.AddressNotAvailable },
39
{ Interop.Error.EAFNOSUPPORT,
SocketError
.AddressFamilyNotSupported },
40
{ Interop.Error.EAGAIN,
SocketError
.WouldBlock },
41
{ Interop.Error.EALREADY,
SocketError
.AlreadyInProgress },
42
{ Interop.Error.EBADF,
SocketError
.OperationAborted },
43
{ Interop.Error.ECANCELED,
SocketError
.OperationAborted },
44
{ Interop.Error.ECONNABORTED,
SocketError
.ConnectionAborted },
45
{ Interop.Error.ECONNREFUSED,
SocketError
.ConnectionRefused },
46
{ Interop.Error.ECONNRESET,
SocketError
.ConnectionReset },
47
{ Interop.Error.EDESTADDRREQ,
SocketError
.DestinationAddressRequired },
48
{ Interop.Error.EFAULT,
SocketError
.Fault },
49
{ Interop.Error.EHOSTDOWN,
SocketError
.HostDown },
50
{ Interop.Error.ENXIO,
SocketError
.HostNotFound }, // not perfect, but closest match available
51
{ Interop.Error.EHOSTUNREACH,
SocketError
.HostUnreachable },
52
{ Interop.Error.EINPROGRESS,
SocketError
.InProgress },
53
{ Interop.Error.EINTR,
SocketError
.Interrupted },
54
{ Interop.Error.EINVAL,
SocketError
.InvalidArgument },
55
{ Interop.Error.EISCONN,
SocketError
.IsConnected },
56
{ Interop.Error.EMFILE,
SocketError
.TooManyOpenSockets },
57
{ Interop.Error.EMSGSIZE,
SocketError
.MessageSize },
58
{ Interop.Error.ENETDOWN,
SocketError
.NetworkDown },
59
{ Interop.Error.ENETRESET,
SocketError
.NetworkReset },
60
{ Interop.Error.ENETUNREACH,
SocketError
.NetworkUnreachable },
61
{ Interop.Error.ENFILE,
SocketError
.TooManyOpenSockets },
62
{ Interop.Error.ENOBUFS,
SocketError
.NoBufferSpaceAvailable },
63
{ Interop.Error.ENODATA,
SocketError
.NoData },
64
{ Interop.Error.ENOENT,
SocketError
.AddressNotAvailable },
65
{ Interop.Error.ENOPROTOOPT,
SocketError
.ProtocolOption },
66
{ Interop.Error.ENOTCONN,
SocketError
.NotConnected },
67
{ Interop.Error.ENOTSOCK,
SocketError
.NotSocket },
68
{ Interop.Error.ENOTSUP,
SocketError
.OperationNotSupported },
69
{ Interop.Error.EPERM,
SocketError
.AccessDenied },
70
{ Interop.Error.EPIPE,
SocketError
.Shutdown },
71
{ Interop.Error.EPFNOSUPPORT,
SocketError
.ProtocolFamilyNotSupported },
72
{ Interop.Error.EPROTONOSUPPORT,
SocketError
.ProtocolNotSupported },
73
{ Interop.Error.EPROTOTYPE,
SocketError
.ProtocolType },
74
{ Interop.Error.ESOCKTNOSUPPORT,
SocketError
.SocketNotSupported },
75
{ Interop.Error.ESHUTDOWN,
SocketError
.Disconnecting },
76
{ Interop.Error.SUCCESS,
SocketError
.Success },
77
{ Interop.Error.ETIMEDOUT,
SocketError
.TimedOut },
80
private static readonly Dictionary<
SocketError
, Interop.Error> s_socketErrorToNativeError = new Dictionary<
SocketError
, Interop.Error>(SocketErrorToNativeErrorCount)
88
{
SocketError
.AccessDenied, Interop.Error.EACCES}, // could also have been EPERM
89
{
SocketError
.AddressAlreadyInUse, Interop.Error.EADDRINUSE },
90
{
SocketError
.AddressNotAvailable, Interop.Error.EADDRNOTAVAIL },
91
{
SocketError
.AddressFamilyNotSupported, Interop.Error.EAFNOSUPPORT },
92
{
SocketError
.AlreadyInProgress, Interop.Error.EALREADY },
93
{
SocketError
.ConnectionAborted, Interop.Error.ECONNABORTED },
94
{
SocketError
.ConnectionRefused, Interop.Error.ECONNREFUSED },
95
{
SocketError
.ConnectionReset, Interop.Error.ECONNRESET },
96
{
SocketError
.DestinationAddressRequired, Interop.Error.EDESTADDRREQ },
97
{
SocketError
.Disconnecting, Interop.Error.ESHUTDOWN },
98
{
SocketError
.Fault, Interop.Error.EFAULT },
99
{
SocketError
.HostDown, Interop.Error.EHOSTDOWN },
100
{
SocketError
.HostNotFound, Interop.Error.EHOSTNOTFOUND },
101
{
SocketError
.HostUnreachable, Interop.Error.EHOSTUNREACH },
102
{
SocketError
.InProgress, Interop.Error.EINPROGRESS },
103
{
SocketError
.Interrupted, Interop.Error.EINTR },
104
{
SocketError
.InvalidArgument, Interop.Error.EINVAL },
105
{
SocketError
.IOPending, Interop.Error.EINPROGRESS },
106
{
SocketError
.IsConnected, Interop.Error.EISCONN },
107
{
SocketError
.MessageSize, Interop.Error.EMSGSIZE },
108
{
SocketError
.NetworkDown, Interop.Error.ENETDOWN },
109
{
SocketError
.NetworkReset, Interop.Error.ENETRESET },
110
{
SocketError
.NetworkUnreachable, Interop.Error.ENETUNREACH },
111
{
SocketError
.NoBufferSpaceAvailable, Interop.Error.ENOBUFS },
112
{
SocketError
.NoData, Interop.Error.ENODATA },
113
{
SocketError
.NotConnected, Interop.Error.ENOTCONN },
114
{
SocketError
.NotSocket, Interop.Error.ENOTSOCK },
115
{
SocketError
.OperationAborted, Interop.Error.ECANCELED },
116
{
SocketError
.OperationNotSupported, Interop.Error.ENOTSUP },
117
{
SocketError
.ProtocolFamilyNotSupported, Interop.Error.EPFNOSUPPORT },
118
{
SocketError
.ProtocolNotSupported, Interop.Error.EPROTONOSUPPORT },
119
{
SocketError
.ProtocolOption, Interop.Error.ENOPROTOOPT },
120
{
SocketError
.ProtocolType, Interop.Error.EPROTOTYPE },
121
{
SocketError
.Shutdown, Interop.Error.EPIPE },
122
{
SocketError
.SocketNotSupported, Interop.Error.ESOCKTNOSUPPORT },
123
{
SocketError
.Success, Interop.Error.SUCCESS },
124
{
SocketError
.TimedOut, Interop.Error.ETIMEDOUT },
125
{
SocketError
.TooManyOpenSockets, Interop.Error.ENFILE }, // could also have been EMFILE
126
{
SocketError
.TryAgain, Interop.Error.EAGAIN }, // not a perfect mapping, but better than nothing
127
{
SocketError
.WouldBlock, Interop.Error.EAGAIN },
128
{
SocketError
.SocketError, Interop.Error.ESOCKETERROR },
131
internal static
SocketError
GetSocketErrorForNativeError(Interop.Error errno)
133
SocketError
result;
136
SocketError
.SocketError; // unknown native error, just treat it as a generic SocketError
139
internal static Interop.Error GetNativeErrorForSocketError(
SocketError
error)
150
internal static bool TryGetNativeErrorForSocketError(
SocketError
error, out Interop.Error errno)
System\Net\NetworkInformation\Ping.RawSocket.cs (8)
281
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.TimedOut)
284
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.MessageSize)
288
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.HostUnreachable)
307
SocketError
result;
314
if (result ==
SocketError
.Success && header.SocketAddressLen > 0)
366
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.TimedOut)
369
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.MessageSize)
376
catch (SocketException ex) when (ex.SocketErrorCode ==
SocketError
.HostUnreachable)
System.Net.Primitives (103)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29
throw new SocketException((int)
SocketError
.AddressFamilyNotSupported);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
34
private static readonly Dictionary<Interop.Error,
SocketError
> s_nativeErrorToSocketError = new Dictionary<Interop.Error,
SocketError
>(NativeErrorToSocketErrorCount)
36
{ Interop.Error.EACCES,
SocketError
.AccessDenied },
37
{ Interop.Error.EADDRINUSE,
SocketError
.AddressAlreadyInUse },
38
{ Interop.Error.EADDRNOTAVAIL,
SocketError
.AddressNotAvailable },
39
{ Interop.Error.EAFNOSUPPORT,
SocketError
.AddressFamilyNotSupported },
40
{ Interop.Error.EAGAIN,
SocketError
.WouldBlock },
41
{ Interop.Error.EALREADY,
SocketError
.AlreadyInProgress },
42
{ Interop.Error.EBADF,
SocketError
.OperationAborted },
43
{ Interop.Error.ECANCELED,
SocketError
.OperationAborted },
44
{ Interop.Error.ECONNABORTED,
SocketError
.ConnectionAborted },
45
{ Interop.Error.ECONNREFUSED,
SocketError
.ConnectionRefused },
46
{ Interop.Error.ECONNRESET,
SocketError
.ConnectionReset },
47
{ Interop.Error.EDESTADDRREQ,
SocketError
.DestinationAddressRequired },
48
{ Interop.Error.EFAULT,
SocketError
.Fault },
49
{ Interop.Error.EHOSTDOWN,
SocketError
.HostDown },
50
{ Interop.Error.ENXIO,
SocketError
.HostNotFound }, // not perfect, but closest match available
51
{ Interop.Error.EHOSTUNREACH,
SocketError
.HostUnreachable },
52
{ Interop.Error.EINPROGRESS,
SocketError
.InProgress },
53
{ Interop.Error.EINTR,
SocketError
.Interrupted },
54
{ Interop.Error.EINVAL,
SocketError
.InvalidArgument },
55
{ Interop.Error.EISCONN,
SocketError
.IsConnected },
56
{ Interop.Error.EMFILE,
SocketError
.TooManyOpenSockets },
57
{ Interop.Error.EMSGSIZE,
SocketError
.MessageSize },
58
{ Interop.Error.ENETDOWN,
SocketError
.NetworkDown },
59
{ Interop.Error.ENETRESET,
SocketError
.NetworkReset },
60
{ Interop.Error.ENETUNREACH,
SocketError
.NetworkUnreachable },
61
{ Interop.Error.ENFILE,
SocketError
.TooManyOpenSockets },
62
{ Interop.Error.ENOBUFS,
SocketError
.NoBufferSpaceAvailable },
63
{ Interop.Error.ENODATA,
SocketError
.NoData },
64
{ Interop.Error.ENOENT,
SocketError
.AddressNotAvailable },
65
{ Interop.Error.ENOPROTOOPT,
SocketError
.ProtocolOption },
66
{ Interop.Error.ENOTCONN,
SocketError
.NotConnected },
67
{ Interop.Error.ENOTSOCK,
SocketError
.NotSocket },
68
{ Interop.Error.ENOTSUP,
SocketError
.OperationNotSupported },
69
{ Interop.Error.EPERM,
SocketError
.AccessDenied },
70
{ Interop.Error.EPIPE,
SocketError
.Shutdown },
71
{ Interop.Error.EPFNOSUPPORT,
SocketError
.ProtocolFamilyNotSupported },
72
{ Interop.Error.EPROTONOSUPPORT,
SocketError
.ProtocolNotSupported },
73
{ Interop.Error.EPROTOTYPE,
SocketError
.ProtocolType },
74
{ Interop.Error.ESOCKTNOSUPPORT,
SocketError
.SocketNotSupported },
75
{ Interop.Error.ESHUTDOWN,
SocketError
.Disconnecting },
76
{ Interop.Error.SUCCESS,
SocketError
.Success },
77
{ Interop.Error.ETIMEDOUT,
SocketError
.TimedOut },
80
private static readonly Dictionary<
SocketError
, Interop.Error> s_socketErrorToNativeError = new Dictionary<
SocketError
, Interop.Error>(SocketErrorToNativeErrorCount)
88
{
SocketError
.AccessDenied, Interop.Error.EACCES}, // could also have been EPERM
89
{
SocketError
.AddressAlreadyInUse, Interop.Error.EADDRINUSE },
90
{
SocketError
.AddressNotAvailable, Interop.Error.EADDRNOTAVAIL },
91
{
SocketError
.AddressFamilyNotSupported, Interop.Error.EAFNOSUPPORT },
92
{
SocketError
.AlreadyInProgress, Interop.Error.EALREADY },
93
{
SocketError
.ConnectionAborted, Interop.Error.ECONNABORTED },
94
{
SocketError
.ConnectionRefused, Interop.Error.ECONNREFUSED },
95
{
SocketError
.ConnectionReset, Interop.Error.ECONNRESET },
96
{
SocketError
.DestinationAddressRequired, Interop.Error.EDESTADDRREQ },
97
{
SocketError
.Disconnecting, Interop.Error.ESHUTDOWN },
98
{
SocketError
.Fault, Interop.Error.EFAULT },
99
{
SocketError
.HostDown, Interop.Error.EHOSTDOWN },
100
{
SocketError
.HostNotFound, Interop.Error.EHOSTNOTFOUND },
101
{
SocketError
.HostUnreachable, Interop.Error.EHOSTUNREACH },
102
{
SocketError
.InProgress, Interop.Error.EINPROGRESS },
103
{
SocketError
.Interrupted, Interop.Error.EINTR },
104
{
SocketError
.InvalidArgument, Interop.Error.EINVAL },
105
{
SocketError
.IOPending, Interop.Error.EINPROGRESS },
106
{
SocketError
.IsConnected, Interop.Error.EISCONN },
107
{
SocketError
.MessageSize, Interop.Error.EMSGSIZE },
108
{
SocketError
.NetworkDown, Interop.Error.ENETDOWN },
109
{
SocketError
.NetworkReset, Interop.Error.ENETRESET },
110
{
SocketError
.NetworkUnreachable, Interop.Error.ENETUNREACH },
111
{
SocketError
.NoBufferSpaceAvailable, Interop.Error.ENOBUFS },
112
{
SocketError
.NoData, Interop.Error.ENODATA },
113
{
SocketError
.NotConnected, Interop.Error.ENOTCONN },
114
{
SocketError
.NotSocket, Interop.Error.ENOTSOCK },
115
{
SocketError
.OperationAborted, Interop.Error.ECANCELED },
116
{
SocketError
.OperationNotSupported, Interop.Error.ENOTSUP },
117
{
SocketError
.ProtocolFamilyNotSupported, Interop.Error.EPFNOSUPPORT },
118
{
SocketError
.ProtocolNotSupported, Interop.Error.EPROTONOSUPPORT },
119
{
SocketError
.ProtocolOption, Interop.Error.ENOPROTOOPT },
120
{
SocketError
.ProtocolType, Interop.Error.EPROTOTYPE },
121
{
SocketError
.Shutdown, Interop.Error.EPIPE },
122
{
SocketError
.SocketNotSupported, Interop.Error.ESOCKTNOSUPPORT },
123
{
SocketError
.Success, Interop.Error.SUCCESS },
124
{
SocketError
.TimedOut, Interop.Error.ETIMEDOUT },
125
{
SocketError
.TooManyOpenSockets, Interop.Error.ENFILE }, // could also have been EMFILE
126
{
SocketError
.TryAgain, Interop.Error.EAGAIN }, // not a perfect mapping, but better than nothing
127
{
SocketError
.WouldBlock, Interop.Error.EAGAIN },
128
{
SocketError
.SocketError, Interop.Error.ESOCKETERROR },
131
internal static
SocketError
GetSocketErrorForNativeError(Interop.Error errno)
133
SocketError
result;
136
SocketError
.SocketError; // unknown native error, just treat it as a generic SocketError
139
internal static Interop.Error GetNativeErrorForSocketError(
SocketError
error)
150
internal static bool TryGetNativeErrorForSocketError(
SocketError
error, out Interop.Error errno)
System\Net\IPAddress.cs (1)
761
private static void ThrowSocketOperationNotSupported() => throw new SocketException(
SocketError
.OperationNotSupported);
System\Net\IPAddressParser.cs (1)
45
throw new FormatException(SR.dns_bad_ip_address, new SocketException(
SocketError
.InvalidArgument));
System\Net\SocketException.cs (6)
16
private readonly
SocketError
_errorCode;
19
public SocketException(int errorCode) : this((
SocketError
)errorCode)
34
public SocketException(int errorCode, string? message) : this((
SocketError
)errorCode, message)
39
internal SocketException(
SocketError
socketError) : base(GetNativeErrorForSocketError(socketError))
45
internal SocketException(
SocketError
socketError, string? message) : base(GetNativeErrorForSocketError(socketError), message)
52
public
SocketError
SocketErrorCode => _errorCode;
System\Net\SocketException.Unix.cs (2)
15
internal SocketException(
SocketError
errorCode, uint platformError) : base((int)platformError)
24
private static int GetNativeErrorForSocketError(
SocketError
error)
System.Net.Quic (6)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29
throw new SocketException((int)
SocketError
.AddressFamilyNotSupported);
System\Net\Quic\Internal\ThrowHelper.cs (4)
83
if (status == QUIC_STATUS_INVALID_ADDRESS) return new SocketException((int)
SocketError
.AddressNotAvailable);
84
if (status == QUIC_STATUS_ADDRESS_IN_USE) return new SocketException((int)
SocketError
.AddressAlreadyInUse);
85
if (status == QUIC_STATUS_UNREACHABLE) return new SocketException((int)
SocketError
.HostUnreachable);
86
if (status == QUIC_STATUS_ADDRESS_NOT_AVAILABLE) return new SocketException((int)
SocketError
.AddressFamilyNotSupported);
System\Net\Quic\QuicConnection.cs (1)
400
throw new SocketException((int)
SocketError
.HostNotFound);
System.Net.Requests (4)
System\Net\FtpWebRequest.cs (2)
920
sEx.SocketErrorCode ==
SocketError
.TimedOut)
939
if (se.SocketErrorCode ==
SocketError
.HostNotFound)
System\Net\WebException.cs (2)
115
case
SocketError
.NoData:
116
case
SocketError
.HostNotFound:
System.Net.Sockets (702)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29
throw new SocketException((int)
SocketError
.AddressFamilyNotSupported);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
34
private static readonly Dictionary<Interop.Error,
SocketError
> s_nativeErrorToSocketError = new Dictionary<Interop.Error,
SocketError
>(NativeErrorToSocketErrorCount)
36
{ Interop.Error.EACCES,
SocketError
.AccessDenied },
37
{ Interop.Error.EADDRINUSE,
SocketError
.AddressAlreadyInUse },
38
{ Interop.Error.EADDRNOTAVAIL,
SocketError
.AddressNotAvailable },
39
{ Interop.Error.EAFNOSUPPORT,
SocketError
.AddressFamilyNotSupported },
40
{ Interop.Error.EAGAIN,
SocketError
.WouldBlock },
41
{ Interop.Error.EALREADY,
SocketError
.AlreadyInProgress },
42
{ Interop.Error.EBADF,
SocketError
.OperationAborted },
43
{ Interop.Error.ECANCELED,
SocketError
.OperationAborted },
44
{ Interop.Error.ECONNABORTED,
SocketError
.ConnectionAborted },
45
{ Interop.Error.ECONNREFUSED,
SocketError
.ConnectionRefused },
46
{ Interop.Error.ECONNRESET,
SocketError
.ConnectionReset },
47
{ Interop.Error.EDESTADDRREQ,
SocketError
.DestinationAddressRequired },
48
{ Interop.Error.EFAULT,
SocketError
.Fault },
49
{ Interop.Error.EHOSTDOWN,
SocketError
.HostDown },
50
{ Interop.Error.ENXIO,
SocketError
.HostNotFound }, // not perfect, but closest match available
51
{ Interop.Error.EHOSTUNREACH,
SocketError
.HostUnreachable },
52
{ Interop.Error.EINPROGRESS,
SocketError
.InProgress },
53
{ Interop.Error.EINTR,
SocketError
.Interrupted },
54
{ Interop.Error.EINVAL,
SocketError
.InvalidArgument },
55
{ Interop.Error.EISCONN,
SocketError
.IsConnected },
56
{ Interop.Error.EMFILE,
SocketError
.TooManyOpenSockets },
57
{ Interop.Error.EMSGSIZE,
SocketError
.MessageSize },
58
{ Interop.Error.ENETDOWN,
SocketError
.NetworkDown },
59
{ Interop.Error.ENETRESET,
SocketError
.NetworkReset },
60
{ Interop.Error.ENETUNREACH,
SocketError
.NetworkUnreachable },
61
{ Interop.Error.ENFILE,
SocketError
.TooManyOpenSockets },
62
{ Interop.Error.ENOBUFS,
SocketError
.NoBufferSpaceAvailable },
63
{ Interop.Error.ENODATA,
SocketError
.NoData },
64
{ Interop.Error.ENOENT,
SocketError
.AddressNotAvailable },
65
{ Interop.Error.ENOPROTOOPT,
SocketError
.ProtocolOption },
66
{ Interop.Error.ENOTCONN,
SocketError
.NotConnected },
67
{ Interop.Error.ENOTSOCK,
SocketError
.NotSocket },
68
{ Interop.Error.ENOTSUP,
SocketError
.OperationNotSupported },
69
{ Interop.Error.EPERM,
SocketError
.AccessDenied },
70
{ Interop.Error.EPIPE,
SocketError
.Shutdown },
71
{ Interop.Error.EPFNOSUPPORT,
SocketError
.ProtocolFamilyNotSupported },
72
{ Interop.Error.EPROTONOSUPPORT,
SocketError
.ProtocolNotSupported },
73
{ Interop.Error.EPROTOTYPE,
SocketError
.ProtocolType },
74
{ Interop.Error.ESOCKTNOSUPPORT,
SocketError
.SocketNotSupported },
75
{ Interop.Error.ESHUTDOWN,
SocketError
.Disconnecting },
76
{ Interop.Error.SUCCESS,
SocketError
.Success },
77
{ Interop.Error.ETIMEDOUT,
SocketError
.TimedOut },
80
private static readonly Dictionary<
SocketError
, Interop.Error> s_socketErrorToNativeError = new Dictionary<
SocketError
, Interop.Error>(SocketErrorToNativeErrorCount)
88
{
SocketError
.AccessDenied, Interop.Error.EACCES}, // could also have been EPERM
89
{
SocketError
.AddressAlreadyInUse, Interop.Error.EADDRINUSE },
90
{
SocketError
.AddressNotAvailable, Interop.Error.EADDRNOTAVAIL },
91
{
SocketError
.AddressFamilyNotSupported, Interop.Error.EAFNOSUPPORT },
92
{
SocketError
.AlreadyInProgress, Interop.Error.EALREADY },
93
{
SocketError
.ConnectionAborted, Interop.Error.ECONNABORTED },
94
{
SocketError
.ConnectionRefused, Interop.Error.ECONNREFUSED },
95
{
SocketError
.ConnectionReset, Interop.Error.ECONNRESET },
96
{
SocketError
.DestinationAddressRequired, Interop.Error.EDESTADDRREQ },
97
{
SocketError
.Disconnecting, Interop.Error.ESHUTDOWN },
98
{
SocketError
.Fault, Interop.Error.EFAULT },
99
{
SocketError
.HostDown, Interop.Error.EHOSTDOWN },
100
{
SocketError
.HostNotFound, Interop.Error.EHOSTNOTFOUND },
101
{
SocketError
.HostUnreachable, Interop.Error.EHOSTUNREACH },
102
{
SocketError
.InProgress, Interop.Error.EINPROGRESS },
103
{
SocketError
.Interrupted, Interop.Error.EINTR },
104
{
SocketError
.InvalidArgument, Interop.Error.EINVAL },
105
{
SocketError
.IOPending, Interop.Error.EINPROGRESS },
106
{
SocketError
.IsConnected, Interop.Error.EISCONN },
107
{
SocketError
.MessageSize, Interop.Error.EMSGSIZE },
108
{
SocketError
.NetworkDown, Interop.Error.ENETDOWN },
109
{
SocketError
.NetworkReset, Interop.Error.ENETRESET },
110
{
SocketError
.NetworkUnreachable, Interop.Error.ENETUNREACH },
111
{
SocketError
.NoBufferSpaceAvailable, Interop.Error.ENOBUFS },
112
{
SocketError
.NoData, Interop.Error.ENODATA },
113
{
SocketError
.NotConnected, Interop.Error.ENOTCONN },
114
{
SocketError
.NotSocket, Interop.Error.ENOTSOCK },
115
{
SocketError
.OperationAborted, Interop.Error.ECANCELED },
116
{
SocketError
.OperationNotSupported, Interop.Error.ENOTSUP },
117
{
SocketError
.ProtocolFamilyNotSupported, Interop.Error.EPFNOSUPPORT },
118
{
SocketError
.ProtocolNotSupported, Interop.Error.EPROTONOSUPPORT },
119
{
SocketError
.ProtocolOption, Interop.Error.ENOPROTOOPT },
120
{
SocketError
.ProtocolType, Interop.Error.EPROTOTYPE },
121
{
SocketError
.Shutdown, Interop.Error.EPIPE },
122
{
SocketError
.SocketNotSupported, Interop.Error.ESOCKTNOSUPPORT },
123
{
SocketError
.Success, Interop.Error.SUCCESS },
124
{
SocketError
.TimedOut, Interop.Error.ETIMEDOUT },
125
{
SocketError
.TooManyOpenSockets, Interop.Error.ENFILE }, // could also have been EMFILE
126
{
SocketError
.TryAgain, Interop.Error.EAGAIN }, // not a perfect mapping, but better than nothing
127
{
SocketError
.WouldBlock, Interop.Error.EAGAIN },
128
{
SocketError
.SocketError, Interop.Error.ESOCKETERROR },
131
internal static
SocketError
GetSocketErrorForNativeError(Interop.Error errno)
133
SocketError
result;
136
SocketError
.SocketError; // unknown native error, just treat it as a generic SocketError
139
internal static Interop.Error GetNativeErrorForSocketError(
SocketError
error)
150
internal static bool TryGetNativeErrorForSocketError(
SocketError
error, out Interop.Error errno)
src\libraries\Common\src\System\Net\Sockets\SocketExceptionFactory.Unix.cs (1)
13
if (SocketErrorPal.TryGetNativeErrorForSocketError((
SocketError
)socketError, out Interop.Error interopErr))
System\Net\Sockets\SafeSocketHandle.cs (5)
26
private
SocketError
_closeSocketResult = unchecked((
SocketError
)0xdeadbeef);
27
private
SocketError
_closeSocketLinger = unchecked((
SocketError
)0xdeadbeef);
152
ret = !OwnsHandle || DoCloseHandle(abortive) ==
SocketError
.Success;
System\Net\Sockets\SafeSocketHandle.Unix.cs (4)
29
internal void RegisterConnectResult(
SocketError
error)
33
case
SocketError
.Success:
34
case
SocketError
.WouldBlock:
226
private unsafe
SocketError
DoCloseHandle(bool abortive)
System\Net\Sockets\Socket.cs (182)
86
SocketError
errorCode = SocketPal.CreateSocket(addressFamily, socketType, protocolType, out _handle);
87
if (errorCode !=
SocketError
.Success)
145
if (SocketPal.GetSockName(handle, bufferPtr, &bufferLength) !=
SocketError
.Success)
188
case
SocketError
.Success:
215
case
SocketError
.InvalidArgument:
279
SocketError
errorCode = SocketPal.GetAvailable(_handle, out argp);
284
if (errorCode !=
SocketError
.Success)
317
SocketError
errorCode = SocketPal.GetSockName(_handle, ptr, &size);
318
if (errorCode !=
SocketError
.Success)
360
SocketError
errorCode = SocketPal.GetPeerName(
364
if (errorCode !=
SocketError
.Success)
420
SocketError
errorCode = InternalSetBlocking(value, out current);
422
if (errorCode !=
SocketError
.Success)
807
UpdateStatusAfterSocketErrorAndThrowException(
SocketError
.InvalidArgument);
811
SocketError
errorCode = SocketPal.Bind(
817
if (errorCode !=
SocketError
.Success)
1018
SocketError
errorCode = SocketPal.Listen(_handle, backlog);
1021
if (errorCode !=
SocketError
.Success)
1059
SocketError
errorCode;
1072
SocketsTelemetry.Log.AfterAccept(
SocketError
.Interrupted, ex.Message);
1077
if (errorCode !=
SocketError
.Success)
1088
SocketsTelemetry.Log.AfterAccept(
SocketError
.Success);
1130
SocketError
errorCode;
1132
if (errorCode !=
SocketError
.Success)
1139
public int Send(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out
SocketError
errorCode)
1157
if (errorCode !=
SocketError
.Success)
1181
SocketError
errorCode;
1183
if (errorCode !=
SocketError
.Success)
1190
public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags, out
SocketError
errorCode)
1205
if (errorCode !=
SocketError
.Success)
1235
int bytesTransferred = Send(buffer, socketFlags, out
SocketError
errorCode);
1236
return errorCode ==
SocketError
.Success ?
1241
public int Send(ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out
SocketError
errorCode)
1251
if (errorCode !=
SocketError
.Success)
1358
SocketError
errorCode = SocketPal.SendTo(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred);
1361
if (errorCode !=
SocketError
.Success)
1440
SocketError
errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred);
1443
if (errorCode !=
SocketError
.Success)
1481
SocketError
errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred);
1484
if (errorCode !=
SocketError
.Success)
1526
SocketError
errorCode;
1528
if (errorCode !=
SocketError
.Success)
1535
public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out
SocketError
errorCode)
1549
if (errorCode !=
SocketError
.Success)
1573
int bytesTransferred = Receive(buffer, socketFlags, out
SocketError
errorCode);
1574
return errorCode ==
SocketError
.Success ?
1579
public int Receive(Span<byte> buffer, SocketFlags socketFlags, out
SocketError
errorCode)
1591
if (errorCode !=
SocketError
.Success)
1617
SocketError
errorCode;
1619
if (errorCode !=
SocketError
.Success)
1626
public int Receive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out
SocketError
errorCode)
1647
if (errorCode !=
SocketError
.Success)
1686
SocketError
errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, offset, size, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred);
1690
if (errorCode !=
SocketError
.Success && errorCode !=
SocketError
.MessageSize)
1697
if (errorCode ==
SocketError
.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived();
1773
SocketError
errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred);
1777
if (errorCode !=
SocketError
.Success && errorCode !=
SocketError
.MessageSize)
1784
if (errorCode ==
SocketError
.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived();
1828
SocketError
errorCode = SocketPal.ReceiveFrom(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred);
1833
if (errorCode !=
SocketError
.Success)
1839
if (socketException.SocketErrorCode !=
SocketError
.MessageSize)
1952
SocketError
errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred);
1957
if (errorCode !=
SocketError
.Success)
1963
if (socketException.SocketErrorCode !=
SocketError
.MessageSize)
2030
SocketError
errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, receivedAddress.Buffer, out int socketAddressSize, out bytesTransferred);
2033
if (errorCode !=
SocketError
.Success)
2061
SocketError
errorCode = SocketPal.WindowsIoctl(_handle, ioControlCode, optionInValue, optionOutValue, out realOptionLength);
2066
if (errorCode !=
SocketError
.Success)
2095
SocketError
errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue);
2100
if (errorCode !=
SocketError
.Success)
2173
SocketError
errorCode = SocketPal.SetRawSockOpt(_handle, optionLevel, optionName, optionValue);
2177
if (errorCode !=
SocketError
.Success)
2204
SocketError
errorCode = SocketPal.GetSockOpt(
2213
if (errorCode !=
SocketError
.Success)
2228
SocketError
errorCode = SocketPal.GetSockOpt(
2238
if (errorCode !=
SocketError
.Success)
2252
SocketError
errorCode = SocketPal.GetSockOpt(
2262
if (errorCode !=
SocketError
.Success)
2294
SocketError
errorCode = SocketPal.GetRawSockOpt(_handle, optionLevel, optionName, optionValue, ref realOptionLength);
2298
if (errorCode !=
SocketError
.Success)
2350
SocketError
errorCode = SocketPal.Poll(_handle, microSeconds, mode, out status);
2354
if (errorCode !=
SocketError
.Success)
2414
SocketError
errorCode = SocketPal.Select(checkRead, checkWrite, checkError, microSeconds);
2417
if (errorCode !=
SocketError
.Success)
2471
SocketError
errorCode;
2478
if (errorCode !=
SocketError
.Success)
2500
public IAsyncResult? BeginSend(byte[] buffer, int offset, int size, SocketFlags socketFlags, out
SocketError
errorCode, AsyncCallback? callback, object? state)
2514
errorCode =
SocketError
.Success;
2527
public IAsyncResult? BeginSend(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out
SocketError
errorCode, AsyncCallback? callback, object? state)
2540
errorCode =
SocketError
.Success;
2546
public int EndSend(IAsyncResult asyncResult, out
SocketError
errorCode) =>
2597
public IAsyncResult? BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out
SocketError
errorCode, AsyncCallback? callback, object? state)
2611
errorCode =
SocketError
.Success;
2623
public IAsyncResult? BeginReceive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out
SocketError
errorCode, AsyncCallback? callback, object? state)
2636
errorCode =
SocketError
.Success;
2642
public int EndReceive(IAsyncResult asyncResult, out
SocketError
errorCode) =>
2645
private static int EndSendReceive(IAsyncResult asyncResult, out
SocketError
errorCode)
2655
errorCode =
SocketError
.Success;
2815
SocketError
errorCode = SocketPal.Shutdown(_handle, _isConnected, _isDisconnected, how);
2820
if (errorCode !=
SocketError
.Success && errorCode !=
SocketError
.NotSocket)
2862
SocketError
socketError;
2869
SocketsTelemetry.Log.AfterAccept(
SocketError
.Interrupted, ex.Message);
2876
return socketError ==
SocketError
.IOPending;
2954
SocketsTelemetry.Log.AfterConnect(
SocketError
.NotSocket, e.ConnectActivity, ex.Message);
2964
SocketError
socketError = canUseConnectEx ?
2967
pending = socketError ==
SocketError
.IOPending;
2971
SocketsTelemetry.Log.AfterConnect(
SocketError
.NotSocket, e.ConnectActivity, ex.Message);
3047
SocketError
socketError;
3059
return socketError ==
SocketError
.IOPending;
3072
SocketError
socketError;
3084
return socketError ==
SocketError
.IOPending;
3128
SocketError
socketError;
3140
bool pending = (socketError ==
SocketError
.IOPending);
3176
SocketError
socketError;
3188
return socketError ==
SocketError
.IOPending;
3201
SocketError
socketError;
3213
return socketError ==
SocketError
.IOPending;
3234
SocketError
socketError;
3246
return socketError ==
SocketError
.IOPending;
3283
SocketError
socketError;
3303
return socketError ==
SocketError
.IOPending;
3354
SocketError
errorCode;
3361
SocketsTelemetry.Log.AfterConnect(
SocketError
.NotSocket, activity, ex.Message);
3366
if (errorCode !=
SocketError
.Success)
3379
SocketsTelemetry.Log.AfterConnect(
SocketError
.Success, activity);
3435
SocketError
errorCode;
3465
if (errorCode !=
SocketError
.Success)
3475
if (errorCode != (
SocketError
)0)
3487
if (errorCode !=
SocketError
.Success || dataAvailable != 0)
3599
UpdateStatusAfterSocketOptionErrorAndThrowException(
SocketError
.ProtocolOption);
3609
SocketError
errorCode;
3626
errorCode ==
SocketError
.Success)
3637
if (errorCode !=
SocketError
.Success)
3645
SocketError
errorCode = SocketPal.SetMulticastOption(_handle, optionName, MR);
3650
if (errorCode !=
SocketError
.Success)
3659
SocketError
errorCode = SocketPal.SetIPv6MulticastOption(_handle, optionName, MR);
3664
if (errorCode !=
SocketError
.Success)
3674
SocketError
errorCode = SocketPal.SetLingerOption(_handle, lref);
3679
if (errorCode !=
SocketError
.Success)
3690
SocketError
errorCode = SocketPal.GetLingerOption(_handle, out lingerOption);
3695
if (errorCode !=
SocketError
.Success)
3706
SocketError
errorCode = SocketPal.GetMulticastOption(_handle, optionName, out multicastOption);
3711
if (errorCode !=
SocketError
.Success)
3723
SocketError
errorCode = SocketPal.GetIPv6MulticastOption(_handle, optionName, out multicastOption);
3728
if (errorCode !=
SocketError
.Success)
3738
private
SocketError
InternalSetBlocking(bool desired, out bool current)
3743
return
SocketError
.Success;
3748
SocketError
errorCode;
3755
errorCode =
SocketError
.NotSocket;
3762
if (errorCode ==
SocketError
.Success)
3900
private void UpdateStatusAfterSocketOptionErrorAndThrowException(
SocketError
error, [CallerMemberName] string? callerName = null)
3903
bool disconnectOnFailure = error !=
SocketError
.ProtocolOption &&
3904
error !=
SocketError
.OperationNotSupported;
3908
private void UpdateStatusAfterSocketErrorAndThrowException(
SocketError
error, bool disconnectOnFailure = true, [CallerMemberName] string? callerName = null)
3925
internal void UpdateStatusAfterSocketError(
SocketError
errorCode, bool disconnectOnFailure = true)
3931
if (disconnectOnFailure && _isConnected && (_handle.IsInvalid || (errorCode !=
SocketError
.WouldBlock &&
3932
errorCode !=
SocketError
.IOPending && errorCode !=
SocketError
.NoBufferSpaceAvailable &&
3933
errorCode !=
SocketError
.TimedOut && errorCode !=
SocketError
.OperationAborted)))
3941
private bool CheckErrorAndUpdateStatus(
SocketError
errorCode)
3943
if (errorCode ==
SocketError
.Success || errorCode ==
SocketError
.IOPending)
3993
private void UpdateReceiveSocketErrorForDisposed(ref
SocketError
socketError, int bytesTransferred)
4000
socketError = IsConnectionOriented ?
SocketError
.ConnectionAborted :
SocketError
.Interrupted;
4004
private void UpdateSendSocketErrorForDisposed(ref
SocketError
socketError)
4008
socketError = IsConnectionOriented ?
SocketError
.ConnectionAborted :
SocketError
.Interrupted;
4012
private void UpdateConnectSocketErrorForDisposed(ref
SocketError
socketError)
4016
socketError =
SocketError
.NotSocket;
4020
private void UpdateAcceptSocketErrorForDisposed(ref
SocketError
socketError)
4024
socketError =
SocketError
.Interrupted;
4037
throw new SocketException((int)
SocketError
.IsConnected);
4058
private static
SocketError
GetSocketErrorFromFaultedTask(Task t)
4064
return
SocketError
.OperationAborted;
4071
ObjectDisposedException =>
SocketError
.OperationAborted,
4072
OperationCanceledException =>
SocketError
.OperationAborted,
4073
_ =>
SocketError
.SocketError
System\Net\Sockets\Socket.Tasks.cs (42)
121
catch (SocketException se) when (se.SocketErrorCode ==
SocketError
.OperationAborted)
184
throw new SocketException((int)
SocketError
.IsConnected);
874
if (saea.SocketError ==
SocketError
.Success)
897
SocketError
error = saea.SocketError;
912
if (error ==
SocketError
.Success)
923
private static Exception GetException(
SocketError
error, bool wrapExceptionsInIOExceptions = false)
1052
SocketError
error = SocketError;
1058
return error ==
SocketError
.Success ?
1074
SocketError
error = SocketError;
1078
return error ==
SocketError
.Success ?
1093
SocketError
error = SocketError;
1097
return error ==
SocketError
.Success ?
1111
SocketError
error = SocketError;
1115
return error ==
SocketError
.Success ?
1132
SocketError
error = SocketError;
1136
return error ==
SocketError
.Success ?
1152
SocketError
error = SocketError;
1156
return error ==
SocketError
.Success ?
1169
SocketError
error = SocketError;
1173
return error ==
SocketError
.Success ?
1186
SocketError
error = SocketError;
1190
return error ==
SocketError
.Success ?
1204
SocketError
error = SocketError;
1208
return error ==
SocketError
.Success ?
1228
SocketError
error = SocketError;
1232
return error ==
SocketError
.Success ?
1245
SocketError
error = SocketError;
1249
return error ==
SocketError
.Success ?
1275
SocketError
error = SocketError;
1281
if (error !=
SocketError
.Success)
1295
SocketError
error = SocketError;
1300
if (error !=
SocketError
.Success)
1313
SocketError
error = SocketError;
1321
if (error !=
SocketError
.Success)
1335
SocketError
error = SocketError;
1342
if (error !=
SocketError
.Success)
1357
SocketError
error = SocketError;
1366
if (error !=
SocketError
.Success)
1376
private void ThrowException(
SocketError
error, CancellationToken cancellationToken)
1381
if (error is
SocketError
.OperationAborted or
SocketError
.ConnectionAborted)
1389
private Exception CreateException(
SocketError
error, bool forAsyncThrow = true)
System\Net\Sockets\Socket.Unix.cs (13)
71
throw new SocketException((int)
SocketError
.NotSocket);
79
throw new SocketException((int)
SocketError
.NotSocket);
122
SocketError
errorCode = ReplaceHandle();
123
if (errorCode !=
SocketError
.Success)
131
internal
SocketError
ReplaceHandle()
154
SocketError
errorCode = SocketPal.CreateSocket(_addressFamily, _socketType, _protocolType, out SafeSocketHandle newHandle);
159
if (errorCode !=
SocketError
.Success)
184
return
SocketError
.Success;
199
throw new SocketException((int)
SocketError
.InvalidArgument);
227
SocketError
errorCode =
SocketError
.Success;
248
if (errorCode !=
SocketError
.Success)
306
catch (TargetInvocationException ex) when (ex.InnerException is SocketException se && se.SocketErrorCode ==
SocketError
.OperationNotSupported)
System\Net\Sockets\SocketAsyncContext.Unix.cs (107)
130
public
SocketError
ErrorCode;
248
ErrorCode =
SocketError
.OperationAborted;
314
ErrorCode =
SocketError
.OperationAborted;
359
public Action<int, Memory<byte>, SocketFlags,
SocketError
>? Callback { get; set; }
382
SocketError
ec = ErrorCode;
410
SocketError
ec = ErrorCode;
443
public Action<int, Memory<byte>, SocketFlags,
SocketError
>? Callback { get; set; }
464
ErrorCode =
SocketError
.Success;
479
if (completed && ErrorCode ==
SocketError
.Success)
494
SocketError
ec = ErrorCode;
514
if (completed && ErrorCode ==
SocketError
.Success)
527
SocketError
ec = ErrorCode;
548
if (completed && ErrorCode ==
SocketError
.Success)
570
public Action<int, Memory<byte>, SocketFlags, IPPacketInformation,
SocketError
>? Callback { get; set; }
575
if (completed && ErrorCode ==
SocketError
.Success)
600
public Action<int, Memory<byte>, SocketFlags, IPPacketInformation,
SocketError
>? Callback { get; set; }
605
if (completed && ErrorCode ==
SocketError
.Success)
622
public Action<IntPtr, Memory<byte>,
SocketError
>? Callback { get; set; }
627
Debug.Assert(ErrorCode ==
SocketError
.Success || AcceptedFileDescriptor == (IntPtr)(-1), $"Unexpected values: ErrorCode={ErrorCode}, AcceptedFileDescriptor={AcceptedFileDescriptor}");
628
if (ErrorCode ==
SocketError
.Success)
640
SocketError
ec = ErrorCode;
660
if (result && ErrorCode ==
SocketError
.Success && Buffer.Length > 0)
662
SocketError
error = context.SendToAsync(Buffer, 0, Buffer.Length, SocketFlags.None, Memory<byte>.Empty, ref BytesTransferred, Callback!, default);
663
if (error !=
SocketError
.Success && error !=
SocketError
.IOPending)
676
SocketError
ec = ErrorCode;
698
public Action<long,
SocketError
>? Callback { get; set; }
1422
operation.ErrorCode =
SocketError
.TimedOut;
1427
private bool ShouldRetrySyncOperation(out
SocketError
errorCode)
1431
errorCode =
SocketError
.Success; // Will be ignored
1436
errorCode =
SocketError
.TimedOut;
1444
public
SocketError
Accept(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd)
1448
SocketError
errorCode;
1453
Debug.Assert(errorCode ==
SocketError
.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}");
1469
public
SocketError
AcceptAsync(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd, Action<IntPtr, Memory<byte>,
SocketError
> callback, CancellationToken cancellationToken)
1476
SocketError
errorCode;
1481
Debug.Assert(errorCode ==
SocketError
.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}");
1502
return
SocketError
.IOPending;
1505
public
SocketError
Connect(Memory<byte> socketAddress)
1514
SocketError
errorCode;
1534
public
SocketError
ConnectAsync(Memory<byte> socketAddress, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback, Memory<byte> buffer, out int sentBytes)
1544
SocketError
errorCode;
1557
if (errorCode ==
SocketError
.Success && remains > 0)
1574
if (operation.ErrorCode ==
SocketError
.Success)
1581
return
SocketError
.IOPending;
1584
public
SocketError
Receive(Memory<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived)
1589
public
SocketError
Receive(Span<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived)
1594
public
SocketError
ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback, CancellationToken cancellationToken)
1599
public unsafe
SocketError
ReceiveFrom(Memory<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived)
1606
SocketError
errorCode;
1632
public unsafe
SocketError
ReceiveFrom(Span<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived)
1637
SocketError
errorCode;
1666
public
SocketError
ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback, CancellationToken cancellationToken = default)
1670
SocketError
errorCode;
1695
return
SocketError
.IOPending;
1698
public
SocketError
ReceiveFromAsync(Memory<byte> buffer, SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback, CancellationToken cancellationToken = default)
1702
SocketError
errorCode;
1731
return
SocketError
.IOPending;
1734
public
SocketError
Receive(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesReceived)
1739
public
SocketError
ReceiveAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback)
1744
public unsafe
SocketError
ReceiveFrom(IList<ArraySegment<byte>> buffers, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived)
1751
SocketError
errorCode;
1776
public
SocketError
ReceiveFromAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback)
1780
SocketError
errorCode;
1809
return
SocketError
.IOPending;
1812
public
SocketError
ReceiveMessageFrom(
1820
SocketError
errorCode;
1849
public unsafe
SocketError
ReceiveMessageFrom(
1857
SocketError
errorCode;
1889
public
SocketError
ReceiveMessageFromAsync(Memory<byte> buffer, IList<ArraySegment<byte>>? buffers, SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, bool isIPv4, bool isIPv6, out int bytesReceived, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, Action<int, Memory<byte>, SocketFlags, IPPacketInformation,
SocketError
> callback, CancellationToken cancellationToken = default)
1893
SocketError
errorCode;
1925
return
SocketError
.IOPending;
1928
public
SocketError
Send(ReadOnlySpan<byte> buffer, SocketFlags flags, int timeout, out int bytesSent) =>
1931
public
SocketError
Send(byte[] buffer, int offset, int count, SocketFlags flags, int timeout, out int bytesSent)
1936
public
SocketError
SendAsync(Memory<byte> buffer, int offset, int count, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback, CancellationToken cancellationToken)
1942
public
SocketError
SendTo(byte[] buffer, int offset, int count, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent)
1949
SocketError
errorCode;
1974
public unsafe
SocketError
SendTo(ReadOnlySpan<byte> buffer, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent)
1981
SocketError
errorCode;
2010
public
SocketError
SendToAsync(Memory<byte> buffer, int offset, int count, SocketFlags flags, Memory<byte> socketAddress, ref int bytesSent, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback, CancellationToken cancellationToken = default)
2014
SocketError
errorCode;
2040
return
SocketError
.IOPending;
2043
public
SocketError
Send(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesSent)
2048
public
SocketError
SendAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback)
2053
public
SocketError
SendTo(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent)
2062
SocketError
errorCode;
2087
public
SocketError
SendToAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, out int bytesSent, Action<int, Memory<byte>, SocketFlags,
SocketError
> callback)
2094
SocketError
errorCode;
2120
return
SocketError
.IOPending;
2123
public
SocketError
SendFile(SafeFileHandle fileHandle, long offset, long count, int timeout, out long bytesSent)
2130
SocketError
errorCode;
2153
public
SocketError
SendFileAsync(SafeFileHandle fileHandle, long offset, long count, out long bytesSent, Action<long,
SocketError
> callback, CancellationToken cancellationToken = default)
2158
SocketError
errorCode;
2181
return
SocketError
.IOPending;
System\Net\Sockets\SocketAsyncEventArgs.cs (22)
55
private
SocketError
_socketError;
287
public
SocketError
SocketError
431
internal void SetResults(
SocketError
socketError, int bytesTransferred, SocketFlags flags)
447
_socketError =
SocketError
.Success;
460
_socketError =
SocketError
.OperationAborted;
464
_socketError =
SocketError
.SocketError;
627
internal void FinishOperationSyncFailure(
SocketError
socketError, int bytesTransferred, SocketFlags flags)
659
internal void FinishOperationAsyncFailure(
SocketError
socketError, int bytesTransferred, SocketFlags flags)
717
SocketError
lastError =
SocketError
.NoData;
784
if (internalArgs.SocketError ==
SocketError
.Success)
792
throw new SocketException((int)
SocketError
.OperationAborted);
804
caughtException = new SocketException((int)
SocketError
.OperationAborted);
827
(caughtException is SocketException se && se.SocketErrorCode ==
SocketError
.OperationAborted))
841
SetResults(
SocketError
.Success, internalArgs.BytesTransferred, internalArgs.SocketFlags);
888
SetResults(
SocketError
.Success, bytesTransferred, flags);
895
SocketError
socketError;
904
if (socketError ==
SocketError
.Success)
927
if (socketError ==
SocketError
.Success)
1032
private void FinishOperationSync(
SocketError
socketError, int bytesTransferred, SocketFlags flags)
1034
Debug.Assert(socketError !=
SocketError
.IOPending);
1036
if (socketError ==
SocketError
.Success)
System\Net\Sockets\SocketAsyncEventArgs.Unix.cs (44)
16
private Action<int, Memory<byte>, SocketFlags,
SocketError
>? _transferCompletionCallback;
26
private void AcceptCompletionCallback(IntPtr acceptedFileDescriptor, Memory<byte> socketAddress,
SocketError
socketError)
33
private void CompleteAcceptOperation(IntPtr acceptedFileDescriptor, Memory<byte> socketAddress,
SocketError
socketError)
36
if (socketError ==
SocketError
.Success)
46
internal unsafe
SocketError
DoOperationAccept(Socket _ /*socket*/, SafeSocketHandle handle, SafeSocketHandle? acceptHandle, CancellationToken cancellationToken)
58
SocketError
socketError = handle.AsyncContext.AcceptAsync(_acceptBuffer!, out int socketAddressLen, out acceptedFd, AcceptCompletionCallback, cancellationToken);
60
if (socketError !=
SocketError
.IOPending)
69
private void ConnectCompletionCallback(int bytesTransferred, Memory<byte> socketAddress, SocketFlags receivedFlags,
SocketError
socketError)
74
internal unsafe
SocketError
DoOperationConnectEx(Socket _ /*socket*/, SafeSocketHandle handle)
76
SocketError
socketError = handle.AsyncContext.ConnectAsync(_socketAddress!.Buffer, ConnectCompletionCallback, _buffer.Slice(_offset, _count), out int sentBytes);
77
if (socketError !=
SocketError
.IOPending)
84
internal unsafe
SocketError
DoOperationConnect(SafeSocketHandle handle)
86
SocketError
socketError = handle.AsyncContext.ConnectAsync(_socketAddress!.Buffer, ConnectCompletionCallback, Memory<byte>.Empty, out int _);
87
if (socketError !=
SocketError
.IOPending)
94
internal
SocketError
DoOperationDisconnect(Socket socket, SafeSocketHandle handle, CancellationToken _ /*cancellationToken*/)
96
SocketError
socketError = SocketPal.Disconnect(socket, handle, _disconnectReuseSocket);
101
private Action<int, Memory<byte>, SocketFlags,
SocketError
> TransferCompletionCallback =>
104
private void TransferCompletionCallbackCore(int bytesTransferred, Memory<byte> socketAddress, SocketFlags receivedFlags,
SocketError
socketError)
117
internal unsafe
SocketError
DoOperationReceive(SafeSocketHandle handle, CancellationToken cancellationToken)
124
SocketError
errorCode;
144
if (errorCode !=
SocketError
.IOPending)
153
internal unsafe
SocketError
DoOperationReceiveFrom(SafeSocketHandle handle, CancellationToken cancellationToken)
159
SocketError
errorCode;
171
if (errorCode !=
SocketError
.IOPending)
180
private void ReceiveMessageFromCompletionCallback(int bytesTransferred, Memory<byte> socketAddress, SocketFlags receivedFlags, IPPacketInformation ipPacketInformation,
SocketError
errorCode)
196
internal unsafe
SocketError
DoOperationReceiveMessageFrom(Socket socket, SafeSocketHandle handle, CancellationToken cancellationToken)
209
SocketError
socketError = handle.AsyncContext.ReceiveMessageFromAsync(_buffer.Slice(_offset, _count), _bufferListInternal, _socketFlags, _socketAddress.Buffer, out socketAddressSize, isIPv4, isIPv6, out bytesReceived, out receivedFlags, out ipPacketInformation, ReceiveMessageFromCompletionCallback, cancellationToken);
210
if (socketError !=
SocketError
.IOPending)
219
internal unsafe
SocketError
DoOperationSend(SafeSocketHandle handle, CancellationToken cancellationToken)
225
SocketError
errorCode;
235
if (errorCode !=
SocketError
.IOPending)
244
internal
SocketError
DoOperationSendPackets(Socket socket, SafeSocketHandle _1 /*handle*/, CancellationToken cancellationToken)
290
if (error ==
SocketError
.Success)
300
return
SocketError
.IOPending;
303
internal
SocketError
DoOperationSendTo(SafeSocketHandle handle, CancellationToken cancellationToken)
309
SocketError
errorCode;
319
if (errorCode !=
SocketError
.IOPending)
345
private
SocketError
FinishOperationAccept(SocketAddress remoteSocketAddress)
367
return
SocketError
.Success;
370
private static
SocketError
FinishOperationConnect()
373
return
SocketError
.Success;
385
private void CompletionCallback(int bytesTransferred, SocketFlags flags,
SocketError
socketError)
387
if (socketError ==
SocketError
.Success)
395
socketError =
SocketError
.OperationAborted;
System\Net\Sockets\SocketPal.Unix.cs (160)
30
public static
SocketError
GetSocketErrorForErrorCode(Interop.Error errorCode)
59
public static unsafe
SocketError
CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, out SafeSocketHandle socket)
64
SocketError
errorCode;
70
errorCode =
SocketError
.Success;
626
public static unsafe bool TryCompleteAccept(SafeSocketHandle socket, Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd, out
SocketError
errorCode)
641
errorCode =
SocketError
.OperationAborted;
652
errorCode =
SocketError
.Success;
665
errorCode =
SocketError
.Success;
669
public static unsafe bool TryStartConnect(SafeSocketHandle socket, Memory<byte> socketAddress, out
SocketError
errorCode) => TryStartConnect(socket, socketAddress, out errorCode, Span<byte>.Empty, false, out int _ );
671
public static unsafe bool TryStartConnect(SafeSocketHandle socket, Memory<byte> socketAddress, out
SocketError
errorCode, Span<byte> data, bool tfo, out int sent)
678
errorCode =
SocketError
.IsConnected;
699
errorCode =
SocketError
.Success;
709
errorCode =
SocketError
.Success;
713
public static unsafe bool TryCompleteConnect(SafeSocketHandle socket, out
SocketError
errorCode)
741
errorCode =
SocketError
.OperationAborted;
748
errorCode =
SocketError
.SocketError;
754
errorCode =
SocketError
.Success;
759
errorCode =
SocketError
.Success;
767
public static bool TryCompleteReceiveFrom(SafeSocketHandle socket, Span<byte> buffer, SocketFlags flags, Span<byte> socketAddress, out int socketAddressLen, out int bytesReceived, out SocketFlags receivedFlags, out
SocketError
errorCode) =>
770
public static bool TryCompleteReceiveFrom(SafeSocketHandle socket, IList<ArraySegment<byte>> buffers, SocketFlags flags, Span<byte> socketAddress, out int socketAddressLen, out int bytesReceived, out SocketFlags receivedFlags, out
SocketError
errorCode) =>
773
public static unsafe bool TryCompleteReceive(SafeSocketHandle socket, Span<byte> buffer, SocketFlags flags, out int bytesReceived, out
SocketError
errorCode)
808
errorCode =
SocketError
.Success;
820
errorCode =
SocketError
.Success;
827
errorCode =
SocketError
.OperationAborted;
832
public static unsafe bool TryCompleteReceiveFrom(SafeSocketHandle socket, Span<byte> buffer, IList<ArraySegment<byte>>? buffers, SocketFlags flags, Span<byte> socketAddress, out int receivedSocketAddressLength, out int bytesReceived, out SocketFlags receivedFlags, out
SocketError
errorCode)
876
errorCode =
SocketError
.Success;
889
errorCode =
SocketError
.Success;
898
errorCode =
SocketError
.OperationAborted;
903
public static unsafe bool TryCompleteReceiveMessageFrom(SafeSocketHandle socket, Span<byte> buffer, IList<ArraySegment<byte>>? buffers, SocketFlags flags, Memory<byte> socketAddress, out int receivedSocketAddressLength, bool isIPv4, bool isIPv6, out int bytesReceived, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out
SocketError
errorCode)
922
errorCode =
SocketError
.Success;
934
errorCode =
SocketError
.Success;
944
errorCode =
SocketError
.OperationAborted;
949
public static bool TryCompleteSendTo(SafeSocketHandle socket, Span<byte> buffer, ref int offset, ref int count, SocketFlags flags, ReadOnlySpan<byte> socketAddress, ref int bytesSent, out
SocketError
errorCode)
955
public static bool TryCompleteSendTo(SafeSocketHandle socket, ReadOnlySpan<byte> buffer, SocketFlags flags, ReadOnlySpan<byte> socketAddress, ref int bytesSent, out
SocketError
errorCode)
961
public static bool TryCompleteSendTo(SafeSocketHandle socket, IList<ArraySegment<byte>> buffers, ref int bufferIndex, ref int offset, SocketFlags flags, ReadOnlySpan<byte> socketAddress, ref int bytesSent, out
SocketError
errorCode)
967
public static bool TryCompleteSendTo(SafeSocketHandle socket, ReadOnlySpan<byte> buffer, IList<ArraySegment<byte>>? buffers, ref int bufferIndex, ref int offset, ref int count, SocketFlags flags, ReadOnlySpan<byte> socketAddress, ref int bytesSent, out
SocketError
errorCode)
995
errorCode =
SocketError
.OperationAborted;
1007
errorCode = successfulSend ?
SocketError
.Success :
SocketError
.WouldBlock;
1019
errorCode =
SocketError
.Success;
1029
errorCode =
SocketError
.TimedOut;
1036
public static bool TryCompleteSendFile(SafeSocketHandle socket, SafeFileHandle handle, ref long offset, ref long count, ref long bytesSent, out
SocketError
errorCode)
1050
errorCode =
SocketError
.OperationAborted;
1062
errorCode =
SocketError
.Success;
1068
errorCode =
SocketError
.Success;
1074
public static
SocketError
SetBlocking(SafeSocketHandle handle, bool shouldBlock, out bool willBlock)
1080
return
SocketError
.Success;
1083
public static unsafe
SocketError
GetSockName(SafeSocketHandle handle, byte* buffer, int* nameLen)
1086
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1089
public static unsafe
SocketError
GetAvailable(SafeSocketHandle handle, out int available)
1095
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1098
public static unsafe
SocketError
GetAtOutOfBandMark(SafeSocketHandle handle, out int atOutOfBandMark)
1104
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1107
public static unsafe
SocketError
GetPeerName(SafeSocketHandle handle, Span<byte> buffer, ref int nameLen)
1117
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1120
public static unsafe
SocketError
Bind(SafeSocketHandle handle, ProtocolType socketProtocolType, ReadOnlySpan<byte> buffer)
1124
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1127
public static
SocketError
Listen(SafeSocketHandle handle, int backlog)
1130
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1133
public static
SocketError
Accept(SafeSocketHandle listenSocket, Memory<byte> socketAddress, out int socketAddressLen, out SafeSocketHandle socket)
1138
SocketError
errorCode;
1147
errorCode =
SocketError
.WouldBlock;
1158
public static
SocketError
Connect(SafeSocketHandle handle, Memory<byte> socketAddress)
1165
SocketError
errorCode;
1174
return
SocketError
.WouldBlock;
1178
public static
SocketError
Send(SafeSocketHandle handle, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out int bytesTransferred)
1189
SocketError
errorCode;
1194
public static
SocketError
Send(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, out int bytesTransferred)
1202
SocketError
errorCode;
1207
public static
SocketError
Send(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out int bytesTransferred)
1215
SocketError
errorCode;
1220
public static
SocketError
SendFile(SafeSocketHandle handle, SafeFileHandle fileHandle)
1231
SocketError
errorCode;
1233
return completed ? errorCode :
SocketError
.WouldBlock;
1236
public static
SocketError
SendTo(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, Memory<byte> socketAddress, out int bytesTransferred)
1244
SocketError
errorCode;
1249
public static
SocketError
SendTo(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, SocketFlags socketFlags, Memory<byte> socketAddress, out int bytesTransferred)
1257
SocketError
errorCode;
1262
public static
SocketError
Receive(SafeSocketHandle handle, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out int bytesTransferred)
1264
SocketError
errorCode;
1273
errorCode =
SocketError
.WouldBlock;
1280
public static
SocketError
Receive(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, out int bytesTransferred)
1287
SocketError
errorCode;
1289
return completed ? errorCode :
SocketError
.WouldBlock;
1292
public static
SocketError
Receive(SafeSocketHandle handle, Span<byte> buffer, SocketFlags socketFlags, out int bytesTransferred)
1299
SocketError
errorCode;
1301
return completed ? errorCode :
SocketError
.WouldBlock;
1304
public static
SocketError
ReceiveMessageFrom(Socket socket, SafeSocketHandle handle, byte[] buffer, int offset, int count, ref SocketFlags socketFlags, SocketAddress socketAddress, out SocketAddress receiveAddress, out IPPacketInformation ipPacketInformation, out int bytesTransferred)
1311
SocketError
errorCode;
1320
errorCode =
SocketError
.WouldBlock;
1330
public static
SocketError
ReceiveMessageFrom(Socket socket, SafeSocketHandle handle, Span<byte> buffer, ref SocketFlags socketFlags, SocketAddress socketAddress, out SocketAddress receiveAddress, out IPPacketInformation ipPacketInformation, out int bytesTransferred)
1337
SocketError
errorCode;
1346
errorCode =
SocketError
.WouldBlock;
1355
public static
SocketError
ReceiveFrom(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesTransferred)
1362
SocketError
errorCode;
1364
return completed ? errorCode :
SocketError
.WouldBlock;
1367
public static
SocketError
ReceiveFrom(SafeSocketHandle handle, Span<byte> buffer, SocketFlags socketFlags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesTransferred)
1374
SocketError
errorCode;
1376
return completed ? errorCode :
SocketError
.WouldBlock;
1379
public static
SocketError
WindowsIoctl(SafeSocketHandle handle, int ioControlCode, byte[]? _ /*optionInValue*/, byte[]? optionOutValue, out int optionLength)
1401
return
SocketError
.Fault;
1405
SocketError
error = ioControlCode == FIONREAD ?
1408
if (error ==
SocketError
.Success)
1421
private static
SocketError
GetErrorAndTrackSetting(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, Interop.Error err)
1426
return
SocketError
.Success;
1431
public static unsafe
SocketError
SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue)
1502
public static unsafe
SocketError
SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue)
1511
public static unsafe
SocketError
SetRawSockOpt(SafeSocketHandle handle, int optionLevel, int optionName, ReadOnlySpan<byte> optionValue)
1525
return
SocketError
.Success;
1532
public static unsafe
SocketError
SetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, MulticastOption optionValue)
1555
public static unsafe
SocketError
SetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, IPv6MulticastOption optionValue)
1572
public static unsafe
SocketError
SetLingerOption(SafeSocketHandle handle, LingerOption optionValue)
1600
public static unsafe
SocketError
GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, out int optionValue)
1607
return
SocketError
.Success;
1612
return
SocketError
.Success;
1621
return getErrorError == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(getErrorError);
1640
return err == Interop.Error.SUCCESS ?
SocketError
.Success : GetSocketErrorForErrorCode(err);
1643
public static unsafe
SocketError
GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue, ref int optionLength)
1656
SocketError
returnError = GetSockOpt(handle, optionLevel, optionName, out outError);
1657
if (returnError ==
SocketError
.Success)
1678
return
SocketError
.Success;
1684
public static unsafe
SocketError
GetRawSockOpt(SafeSocketHandle handle, int optionLevel, int optionName, Span<byte> optionValue, ref int optionLength)
1696
return
SocketError
.Success;
1703
public static unsafe
SocketError
GetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out MulticastOption? optionValue)
1725
return
SocketError
.Success;
1728
public static unsafe
SocketError
GetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out IPv6MulticastOption? optionValue)
1745
return
SocketError
.Success;
1748
public static unsafe
SocketError
GetLingerOption(SafeSocketHandle handle, out LingerOption? optionValue)
1759
return
SocketError
.Success;
1762
public static unsafe
SocketError
Poll(SafeSocketHandle handle, int microseconds, SelectMode mode, out bool status)
1789
return
SocketError
.Success;
1792
public static unsafe
SocketError
Select(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds)
1835
private static
SocketError
SelectViaSelect(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds)
1884
return (
SocketError
)0;
1932
private static unsafe
SocketError
SelectViaPoll(
1980
return
SocketError
.Success;
2049
public static
SocketError
Shutdown(SafeSocketHandle handle, bool isConnected, bool isDisconnected, SocketShutdown how)
2055
return
SocketError
.Success;
2064
return
SocketError
.Success;
2070
private static
SocketError
SendFileAsync(SafeSocketHandle handle, SafeFileHandle fileHandle, long offset, long count, CancellationToken cancellationToken, Action<long,
SocketError
> callback)
2073
SocketError
socketError = handle.AsyncContext.SendFileAsync(fileHandle, offset, count, out bytesSent, callback, cancellationToken);
2074
if (socketError ==
SocketError
.Success)
2076
callback(bytesSent,
SocketError
.Success);
2082
Socket socket, TransmitFileOptions options, SendPacketsElement[] elements, SafeFileHandle[] fileHandles, CancellationToken cancellationToken, Action<long,
SocketError
> callback)
2084
SocketError
error =
SocketError
.Success;
2108
var tcs = new TaskCompletionSource<
SocketError
>();
2117
if (error ==
SocketError
.IOPending)
2121
if (error !=
SocketError
.Success)
2132
if (error !=
SocketError
.Success)
2147
exc is ArgumentException ?
SocketError
.InvalidArgument :
2148
exc is OperationCanceledException ?
SocketError
.OperationAborted :
2149
SocketError
.SocketError;
2157
internal static
SocketError
Disconnect(Socket socket, SafeSocketHandle handle, bool reuseSocket)
2164
SocketError
.Success;
2191
SocketError
errorCode = GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Error, out int optionValue);
2192
if (errorCode !=
SocketError
.Success)
2197
success = (
SocketError
)optionValue ==
SocketError
.Success;
System\Net\Sockets\SocketsTelemetry.cs (25)
51
private void ConnectFailed(
SocketError
error, string? exceptionMessage)
75
private void AcceptFailed(
SocketError
error, string? exceptionMessage)
145
public void AfterConnect(
SocketError
error, Activity? activity, string? exceptionMessage = null)
152
if (error !=
SocketError
.Success)
161
if (error ==
SocketError
.Success)
193
public void AfterAccept(
SocketError
error, string? exceptionMessage = null)
195
if (error ==
SocketError
.Success)
234
private static string GetErrorType(
SocketError
socketError) => socketError switch
239
SocketError
.NetworkDown => "network_down",
240
SocketError
.AddressAlreadyInUse => "address_already_in_use",
241
SocketError
.Interrupted => "interrupted",
242
SocketError
.InProgress => "in_progress",
243
SocketError
.AlreadyInProgress => "already_in_progress",
244
SocketError
.AddressNotAvailable => "address_not_available",
245
SocketError
.AddressFamilyNotSupported => "address_family_not_supported",
246
SocketError
.ConnectionRefused => "connection_refused",
247
SocketError
.Fault => "fault",
248
SocketError
.InvalidArgument => "invalid_argument",
249
SocketError
.IsConnected => "is_connected",
250
SocketError
.NetworkUnreachable => "network_unreachable",
251
SocketError
.HostUnreachable => "host_unreachable",
252
SocketError
.NoBufferSpaceAvailable => "no_buffer_space_available",
253
SocketError
.TimedOut => "timed_out",
254
SocketError
.AccessDenied => "access_denied",
255
SocketError
.ProtocolType => "protocol_type",
System\Net\Sockets\UDPClient.cs (4)
427
throw new SocketException((int)
SocketError
.OperationNotSupported);
447
throw new SocketException((int)
SocketError
.OperationNotSupported);
515
throw new SocketException((int)
SocketError
.OperationNotSupported);
795
throw new SocketException((int)
SocketError
.NotConnected);
System.ServiceModel.UnixDomainSocket (8)
System\ServiceModel\Channels\SocketAwaitableEventArgs.cs (8)
41
var
error = SocketError;
43
return error ==
SocketError
.Success
58
var
error = SocketError;
60
return error ==
SocketError
.Success
83
if (SocketError !=
SocketError
.Success)
95
if (SocketError !=
SocketError
.Success)
101
protected static SocketException CreateException(
SocketError
e)
109
SocketError ==
SocketError
.Success ? ValueTaskSourceStatus.Succeeded :