1027 references to SocketError
ClientSample (9)
Tcp\SocketAwaitable.cs (3)
24private SocketError _error; 40if (_error != SocketError.Success) 62public void Complete(int bytesTransferred, SocketError socketError)
Tcp\TcpConnection.cs (6)
116catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionReset) 120catch (SocketException ex) when (ex.SocketErrorCode == SocketError.OperationAborted || 121ex.SocketErrorCode == SocketError.ConnectionAborted || 122ex.SocketErrorCode == SocketError.Interrupted || 123ex.SocketErrorCode == SocketError.InvalidArgument) 191catch (SocketException ex) when (ex.SocketErrorCode == SocketError.OperationAborted)
dotnet-svcutil-lib (2)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\CoreClrSocketConnection.cs (2)
481if (_asyncWriteEventArgs.SocketError == SocketError.Success) 720if (_asyncReadEventArgs.SocketError == SocketError.Success)
HttpStress (1)
Program.cs (1)
597if (e is HttpRequestException hre && hre.InnerException is SocketException se && se.SocketErrorCode == SocketError.AddressAlreadyInUse)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (1)
Internal\QuicConnectionListener.cs (1)
134catch (SocketException e) when (e.SocketErrorCode == SocketError.AddressAlreadyInUse)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (21)
Internal\SocketAwaitableEventArgs.cs (3)
51if (SocketError != SocketError.Success) 59protected static SocketException CreateException(SocketError e) 67SocketError == SocketError.Success ? ValueTaskSourceStatus.Succeeded :
Internal\SocketConnection.cs (8)
421private static bool IsConnectionResetError(SocketError errorCode) 423return errorCode == SocketError.ConnectionReset || 424errorCode == SocketError.Shutdown || 425(errorCode == SocketError.ConnectionAborted && OperatingSystem.IsWindows()); 428private static bool IsConnectionAbortError(SocketError errorCode) 431return errorCode == SocketError.OperationAborted || 432errorCode == SocketError.Interrupted || 433(errorCode == SocketError.InvalidArgument && !OperatingSystem.IsWindows());
Internal\SocketReceiver.cs (4)
25var error = SocketError; 27return error == SocketError.Success 42var error = SocketError; 44return error == SocketError.Success
Internal\SocketSender.cs (4)
35var error = SocketError; 37return error == SocketError.Success 69var error = SocketError; 71return error == SocketError.Success
SocketConnectionListener.cs (2)
46catch (SocketException e) when (e.SocketErrorCode == SocketError.AddressAlreadyInUse) 82catch (SocketException e) when (e.SocketErrorCode == SocketError.OperationAborted)
Microsoft.Extensions.Diagnostics.ExceptionSummarization (5)
HttpExceptionSummaryProvider.cs (5)
25private static readonly FrozenDictionary<SocketError, int> _socketErrorMap; 37var socketErrors = new Dictionary<SocketError, int>(); 42foreach (var v in Enum.GetValues(typeof(SocketError))) 44var socketError = (SocketError)v!;
Microsoft.Extensions.Diagnostics.Probes.Tests (1)
TcpEndpointProbesServiceTests.cs (1)
109if (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)
48ex.SocketErrorCode == SocketError.NetworkUnreachable 49|| ex.SocketErrorCode == SocketError.HostNotFound)
src\Servers\Kestrel\test\BindTests\AddressRegistrationTests.cs (2)
1231return mre.Wait(5000) && socketArgs.SocketError == SocketError.Success; 1236return socketArgs.SocketError == SocketError.Success;
Sockets.FunctionalTests (2)
src\Servers\Kestrel\shared\test\TransportTestHelpers\HostNameIsReachableAttribute.cs (2)
48ex.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)
54case SocketError.AddressAlreadyInUse: 55case SocketError.AddressNotAvailable: 56case SocketError.ConnectionRefused:
System\IO\Pipes\PipeStream.Unix.cs (1)
334if (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)
157socketException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain)
System.Net.HttpListener (1)
System\Net\Managed\HttpEndPointListener.cs (1)
110Socket? accepted = args.SocketError == SocketError.Success ? args.AcceptSocket : null;
System.Net.NameResolution (23)
System\Net\Dns.cs (6)
435SocketError errorCode = NameResolutionPal.TryGetAddrInfo(hostName, justAddresses, addressFamily, out string? newHostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode); 437if (errorCode != SocketError.Success) 482SocketError errorCode; 487if (errorCode != SocketError.Success) 515if (errorCode != SocketError.Success) 788private static SocketException CreateException(SocketError error, int nativeError) =>
System\Net\NameResolutionPal.Unix.cs (13)
28private static SocketError GetSocketErrorForNativeError(int error) 33return SocketError.Success; 35return SocketError.TryAgain; 38return SocketError.InvalidArgument; 40return SocketError.NoRecovery; 42return SocketError.AddressFamilyNotSupported; 44return SocketError.HostNotFound; 49return SocketError.SocketError; 52return SocketError.SocketError; 131public static unsafe SocketError TryGetAddrInfo(string name, bool justAddresses, AddressFamily addressFamily, out string? hostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode) 152return SocketError.Success; 155public static unsafe string? TryGetNameInfo(IPAddress addr, out SocketError socketError, out int nativeErrorCode) 190return socketError == SocketError.Success ? Utf8StringMarshaller.ConvertToManaged(buffer) : null;
System\Net\NameResolutionTelemetry.cs (4)
147SocketError.HostNotFound => "host_not_found", 148SocketError.TryAgain => "try_again", 149SocketError.AddressFamilyNotSupported => "address_family_not_supported", 150SocketError.NoRecovery => "no_recovery",
System.Net.NetworkInformation (2)
src\libraries\Common\src\System\Net\NetworkInformation\NetworkInformationException.cs (1)
44internal NetworkInformationException(SocketError socketError) : base((int)socketError)
System\Net\NetworkInformation\NetworkAddressChange.Unix.cs (1)
206catch (SocketException se) when (se.SocketErrorCode == SocketError.OperationAborted)
System.Net.Ping (102)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReceiveSocketError.cs (1)
13internal static unsafe partial SocketError ReceiveSocketError(SafeHandle socket, MessageHeader* messageHeader);
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
34private 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 }, 80private 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 }, 131internal static SocketError GetSocketErrorForNativeError(Interop.Error errno) 133SocketError result; 136SocketError.SocketError; // unknown native error, just treat it as a generic SocketError 139internal static Interop.Error GetNativeErrorForSocketError(SocketError error) 150internal static bool TryGetNativeErrorForSocketError(SocketError error, out Interop.Error errno)
System\Net\NetworkInformation\Ping.RawSocket.cs (8)
281catch (SocketException ex) when (ex.SocketErrorCode == SocketError.TimedOut) 284catch (SocketException ex) when (ex.SocketErrorCode == SocketError.MessageSize) 288catch (SocketException ex) when (ex.SocketErrorCode == SocketError.HostUnreachable) 307SocketError result; 314if (result == SocketError.Success && header.SocketAddressLen > 0) 366catch (SocketException ex) when (ex.SocketErrorCode == SocketError.TimedOut) 369catch (SocketException ex) when (ex.SocketErrorCode == SocketError.MessageSize) 376catch (SocketException ex) when (ex.SocketErrorCode == SocketError.HostUnreachable)
System.Net.Primitives (104)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
34private 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 }, 80private 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 }, 131internal static SocketError GetSocketErrorForNativeError(Interop.Error errno) 133SocketError result; 136SocketError.SocketError; // unknown native error, just treat it as a generic SocketError 139internal static Interop.Error GetNativeErrorForSocketError(SocketError error) 150internal static bool TryGetNativeErrorForSocketError(SocketError error, out Interop.Error errno)
System\Net\IPAddress.cs (2)
772private void ThrowSocketOperationNotSupported() => throw new SocketException(SocketError.OperationNotSupported, SR.Format(SR.net_SocketException_OperationNotSupported, AddressFamily)); 775private static void ThrowSocketOperationNotSupportedReadOnly() => throw new SocketException(SocketError.OperationNotSupported, SR.net_SocketException_OperationNotSupported_ReadOnlyIPAddress);
System\Net\IPAddressParser.cs (1)
63throw new FormatException(SR.dns_bad_ip_address, new SocketException(SocketError.InvalidArgument));
System\Net\SocketException.cs (6)
16private readonly SocketError _errorCode; 19public SocketException(int errorCode) : this((SocketError)errorCode) 34public SocketException(int errorCode, string? message) : this((SocketError)errorCode, message) 39internal SocketException(SocketError socketError) : base(GetNativeErrorForSocketError(socketError)) 45internal SocketException(SocketError socketError, string? message) : base(GetNativeErrorForSocketError(socketError), message) 52public SocketError SocketErrorCode => _errorCode;
System\Net\SocketException.Unix.cs (2)
15internal SocketException(SocketError errorCode, uint platformError) : base((int)platformError) 24private static int GetNativeErrorForSocketError(SocketError error)
System.Net.Quic (6)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
System\Net\Quic\Internal\ThrowHelper.cs (4)
83if (status == QUIC_STATUS_INVALID_ADDRESS) return new SocketException((int)SocketError.AddressNotAvailable); 84if (status == QUIC_STATUS_ADDRESS_IN_USE) return new SocketException((int)SocketError.AddressAlreadyInUse); 85if (status == QUIC_STATUS_UNREACHABLE) return new SocketException((int)SocketError.HostUnreachable); 86if (status == QUIC_STATUS_ADDRESS_NOT_AVAILABLE) return new SocketException((int)SocketError.AddressFamilyNotSupported);
System\Net\Quic\QuicConnection.cs (1)
401throw new SocketException((int)SocketError.HostNotFound);
System.Net.Requests (4)
System\Net\FtpWebRequest.cs (2)
918sEx.SocketErrorCode == SocketError.TimedOut) 937if (se.SocketErrorCode == SocketError.HostNotFound)
System\Net\WebException.cs (2)
115case SocketError.NoData: 116case SocketError.HostNotFound:
System.Net.Sockets (709)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
34private 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 }, 80private 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 }, 131internal static SocketError GetSocketErrorForNativeError(Interop.Error errno) 133SocketError result; 136SocketError.SocketError; // unknown native error, just treat it as a generic SocketError 139internal static Interop.Error GetNativeErrorForSocketError(SocketError error) 150internal static bool TryGetNativeErrorForSocketError(SocketError error, out Interop.Error errno)
src\libraries\Common\src\System\Net\Sockets\SocketExceptionFactory.Unix.cs (1)
13if (SocketErrorPal.TryGetNativeErrorForSocketError((SocketError)socketError, out Interop.Error interopErr))
System\Net\Sockets\SafeSocketHandle.cs (5)
26private SocketError _closeSocketResult = unchecked((SocketError)0xdeadbeef); 27private SocketError _closeSocketLinger = unchecked((SocketError)0xdeadbeef); 152ret = !OwnsHandle || DoCloseHandle(abortive) == SocketError.Success;
System\Net\Sockets\SafeSocketHandle.Unix.cs (4)
81internal void RegisterConnectResult(SocketError error) 85case SocketError.Success: 86case SocketError.WouldBlock: 227private unsafe SocketError DoCloseHandle(bool abortive)
System\Net\Sockets\SafeSocketHandle.Unix.OptionTracking.cs (8)
42SocketError errorCode = SocketPal.GetLingerOption(this, out lingerOption); 43if (errorCode != SocketError.Success) 71SocketError errorCode = SocketPal.GetSockOpt(this, level, name, out values[i]); 72if (errorCode != SocketError.Success) 90SocketError errorCode = SocketPal.SetLingerOption(this, lingerOption); 91if (NetEventSource.Log.IsEnabled() && errorCode != SocketError.Success) NetEventSource.Info(this, $"SetLingerOption returned errorCode:{errorCode}"); 103SocketError errorCode = SocketPal.SetSockOpt(this, level, name, values[i]); 104if (NetEventSource.Log.IsEnabled() && errorCode != SocketError.Success) NetEventSource.Info(this, $"GetSockOpt({level},{name}) returned errorCode:{errorCode}");
System\Net\Sockets\Socket.cs (182)
86SocketError errorCode = SocketPal.CreateSocket(addressFamily, socketType, protocolType, out _handle); 87if (errorCode != SocketError.Success) 145if (SocketPal.GetSockName(handle, bufferPtr, &bufferLength) != SocketError.Success) 188case SocketError.Success: 215case SocketError.InvalidArgument: 279SocketError errorCode = SocketPal.GetAvailable(_handle, out argp); 284if (errorCode != SocketError.Success) 317SocketError errorCode = SocketPal.GetSockName(_handle, ptr, &size); 318if (errorCode != SocketError.Success) 360SocketError errorCode = SocketPal.GetPeerName( 364if (errorCode != SocketError.Success) 420SocketError errorCode = InternalSetBlocking(value, out current); 422if (errorCode != SocketError.Success) 807UpdateStatusAfterSocketErrorAndThrowException(SocketError.InvalidArgument); 811SocketError errorCode = SocketPal.Bind( 817if (errorCode != SocketError.Success) 1016SocketError errorCode = SocketPal.Listen(_handle, backlog); 1019if (errorCode != SocketError.Success) 1057SocketError errorCode; 1070SocketsTelemetry.Log.AfterAccept(SocketError.Interrupted, ex.Message); 1075if (errorCode != SocketError.Success) 1086SocketsTelemetry.Log.AfterAccept(SocketError.Success); 1128SocketError errorCode; 1130if (errorCode != SocketError.Success) 1137public int Send(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode) 1155if (errorCode != SocketError.Success) 1179SocketError errorCode; 1181if (errorCode != SocketError.Success) 1188public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode) 1203if (errorCode != SocketError.Success) 1233int bytesTransferred = Send(buffer, socketFlags, out SocketError errorCode); 1234return errorCode == SocketError.Success ? 1239public int Send(ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out SocketError errorCode) 1249if (errorCode != SocketError.Success) 1356SocketError errorCode = SocketPal.SendTo(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1359if (errorCode != SocketError.Success) 1438SocketError errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1441if (errorCode != SocketError.Success) 1479SocketError errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1482if (errorCode != SocketError.Success) 1524SocketError errorCode; 1526if (errorCode != SocketError.Success) 1533public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode) 1547if (errorCode != SocketError.Success) 1571int bytesTransferred = Receive(buffer, socketFlags, out SocketError errorCode); 1572return errorCode == SocketError.Success ? 1577public int Receive(Span<byte> buffer, SocketFlags socketFlags, out SocketError errorCode) 1589if (errorCode != SocketError.Success) 1615SocketError errorCode; 1617if (errorCode != SocketError.Success) 1624public int Receive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode) 1645if (errorCode != SocketError.Success) 1684SocketError errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, offset, size, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred); 1688if (errorCode != SocketError.Success && errorCode != SocketError.MessageSize) 1695if (errorCode == SocketError.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived(); 1771SocketError errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred); 1775if (errorCode != SocketError.Success && errorCode != SocketError.MessageSize) 1782if (errorCode == SocketError.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived(); 1826SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred); 1831if (errorCode != SocketError.Success) 1837if (socketException.SocketErrorCode != SocketError.MessageSize) 1950SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred); 1955if (errorCode != SocketError.Success) 1961if (socketException.SocketErrorCode != SocketError.MessageSize) 2028SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, receivedAddress.Buffer, out int socketAddressSize, out bytesTransferred); 2031if (errorCode != SocketError.Success) 2059SocketError errorCode = SocketPal.WindowsIoctl(_handle, ioControlCode, optionInValue, optionOutValue, out realOptionLength); 2064if (errorCode != SocketError.Success) 2093SocketError errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue); 2098if (errorCode != SocketError.Success) 2171SocketError errorCode = SocketPal.SetRawSockOpt(_handle, optionLevel, optionName, optionValue); 2175if (errorCode != SocketError.Success) 2202SocketError errorCode = SocketPal.GetSockOpt( 2211if (errorCode != SocketError.Success) 2226SocketError errorCode = SocketPal.GetSockOpt( 2236if (errorCode != SocketError.Success) 2250SocketError errorCode = SocketPal.GetSockOpt( 2260if (errorCode != SocketError.Success) 2292SocketError errorCode = SocketPal.GetRawSockOpt(_handle, optionLevel, optionName, optionValue, ref realOptionLength); 2296if (errorCode != SocketError.Success) 2348SocketError errorCode = SocketPal.Poll(_handle, microSeconds, mode, out status); 2352if (errorCode != SocketError.Success) 2412SocketError errorCode = SocketPal.Select(checkRead, checkWrite, checkError, microSeconds); 2415if (errorCode != SocketError.Success) 2469SocketError errorCode; 2476if (errorCode != SocketError.Success) 2498public IAsyncResult? BeginSend(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2512errorCode = SocketError.Success; 2525public IAsyncResult? BeginSend(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2538errorCode = SocketError.Success; 2544public int EndSend(IAsyncResult asyncResult, out SocketError errorCode) => 2595public IAsyncResult? BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2609errorCode = SocketError.Success; 2621public IAsyncResult? BeginReceive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2634errorCode = SocketError.Success; 2640public int EndReceive(IAsyncResult asyncResult, out SocketError errorCode) => 2643private static int EndSendReceive(IAsyncResult asyncResult, out SocketError errorCode) 2653errorCode = SocketError.Success; 2813SocketError errorCode = SocketPal.Shutdown(_handle, _isConnected, _isDisconnected, how); 2818if (errorCode != SocketError.Success && errorCode != SocketError.NotSocket) 2860SocketError socketError; 2867SocketsTelemetry.Log.AfterAccept(SocketError.Interrupted, ex.Message); 2874return socketError == SocketError.IOPending; 2953SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message); 2963SocketError socketError = canUseConnectEx ? 2966pending = socketError == SocketError.IOPending; 2970SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message); 3046SocketError socketError; 3058return socketError == SocketError.IOPending; 3071SocketError socketError; 3083return socketError == SocketError.IOPending; 3127SocketError socketError; 3139bool pending = (socketError == SocketError.IOPending); 3175SocketError socketError; 3187return socketError == SocketError.IOPending; 3200SocketError socketError; 3212return socketError == SocketError.IOPending; 3233SocketError socketError; 3245return socketError == SocketError.IOPending; 3282SocketError socketError; 3302return socketError == SocketError.IOPending; 3353SocketError errorCode; 3360SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, activity, ex.Message); 3365if (errorCode != SocketError.Success) 3378SocketsTelemetry.Log.AfterConnect(SocketError.Success, activity); 3434SocketError errorCode; 3464if (errorCode != SocketError.Success) 3474if (errorCode != (SocketError)0) 3486if (errorCode != SocketError.Success || dataAvailable != 0) 3598UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError.ProtocolOption); 3608SocketError errorCode; 3625errorCode == SocketError.Success) 3636if (errorCode != SocketError.Success) 3644SocketError errorCode = SocketPal.SetMulticastOption(_handle, optionName, MR); 3649if (errorCode != SocketError.Success) 3658SocketError errorCode = SocketPal.SetIPv6MulticastOption(_handle, optionName, MR); 3663if (errorCode != SocketError.Success) 3673SocketError errorCode = SocketPal.SetLingerOption(_handle, lref); 3678if (errorCode != SocketError.Success) 3689SocketError errorCode = SocketPal.GetLingerOption(_handle, out lingerOption); 3694if (errorCode != SocketError.Success) 3705SocketError errorCode = SocketPal.GetMulticastOption(_handle, optionName, out multicastOption); 3710if (errorCode != SocketError.Success) 3722SocketError errorCode = SocketPal.GetIPv6MulticastOption(_handle, optionName, out multicastOption); 3727if (errorCode != SocketError.Success) 3737private SocketError InternalSetBlocking(bool desired, out bool current) 3742return SocketError.Success; 3747SocketError errorCode; 3754errorCode = SocketError.NotSocket; 3761if (errorCode == SocketError.Success) 3899private void UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, [CallerMemberName] string? callerName = null) 3902bool disconnectOnFailure = error != SocketError.ProtocolOption && 3903error != SocketError.OperationNotSupported; 3907private void UpdateStatusAfterSocketErrorAndThrowException(SocketError error, bool disconnectOnFailure = true, [CallerMemberName] string? callerName = null) 3924internal void UpdateStatusAfterSocketError(SocketError errorCode, bool disconnectOnFailure = true) 3930if (disconnectOnFailure && _isConnected && (_handle.IsInvalid || (errorCode != SocketError.WouldBlock && 3931errorCode != SocketError.IOPending && errorCode != SocketError.NoBufferSpaceAvailable && 3932errorCode != SocketError.TimedOut && errorCode != SocketError.OperationAborted))) 3940private bool CheckErrorAndUpdateStatus(SocketError errorCode) 3942if (errorCode == SocketError.Success || errorCode == SocketError.IOPending) 3992private void UpdateReceiveSocketErrorForDisposed(ref SocketError socketError, int bytesTransferred) 3999socketError = IsConnectionOriented ? SocketError.ConnectionAborted : SocketError.Interrupted; 4003private void UpdateSendSocketErrorForDisposed(ref SocketError socketError) 4007socketError = IsConnectionOriented ? SocketError.ConnectionAborted : SocketError.Interrupted; 4011private void UpdateConnectSocketErrorForDisposed(ref SocketError socketError) 4015socketError = SocketError.NotSocket; 4019private void UpdateAcceptSocketErrorForDisposed(ref SocketError socketError) 4023socketError = SocketError.Interrupted; 4036throw new SocketException((int)SocketError.IsConnected); 4057private static SocketError GetSocketErrorFromFaultedTask(Task t) 4063return SocketError.OperationAborted; 4070ObjectDisposedException => SocketError.OperationAborted, 4071OperationCanceledException => SocketError.OperationAborted, 4072_ => SocketError.SocketError
System\Net\Sockets\Socket.Tasks.cs (41)
158throw new SocketException((int)SocketError.IsConnected); 848if (saea.SocketError == SocketError.Success) 871SocketError error = saea.SocketError; 886if (error == SocketError.Success) 897private static Exception GetException(SocketError error, bool wrapExceptionsInIOExceptions = false) 1026SocketError error = SocketError; 1032return error == SocketError.Success ? 1048SocketError error = SocketError; 1052return error == SocketError.Success ? 1067SocketError error = SocketError; 1071return error == SocketError.Success ? 1085SocketError error = SocketError; 1089return error == SocketError.Success ? 1106SocketError error = SocketError; 1110return error == SocketError.Success ? 1126SocketError error = SocketError; 1130return error == SocketError.Success ? 1143SocketError error = SocketError; 1147return error == SocketError.Success ? 1160SocketError error = SocketError; 1164return error == SocketError.Success ? 1178SocketError error = SocketError; 1182return error == SocketError.Success ? 1203SocketError error = SocketError; 1207return error == SocketError.Success ? 1220SocketError error = SocketError; 1224return error == SocketError.Success ? 1250SocketError error = SocketError; 1256if (error != SocketError.Success) 1270SocketError error = SocketError; 1275if (error != SocketError.Success) 1288SocketError error = SocketError; 1296if (error != SocketError.Success) 1310SocketError error = SocketError; 1317if (error != SocketError.Success) 1332SocketError error = SocketError; 1341if (error != SocketError.Success) 1351private void ThrowException(SocketError error, CancellationToken cancellationToken) 1356if (error is SocketError.OperationAborted or SocketError.ConnectionAborted) 1364private Exception CreateException(SocketError error, bool forAsyncThrow = true)
System\Net\Sockets\Socket.Unix.cs (13)
73throw new SocketException((int)SocketError.NotSocket); 81throw new SocketException((int)SocketError.NotSocket); 124SocketError errorCode = ReplaceHandle(); 125if (errorCode != SocketError.Success) 133internal SocketError ReplaceHandle() 143SocketError errorCode = SocketPal.CreateSocket(_addressFamily, _socketType, _protocolType, out SafeSocketHandle newHandle); 148if (errorCode != SocketError.Success) 162return SocketError.Success; 177throw new SocketException((int)SocketError.InvalidArgument); 205SocketError errorCode = SocketError.Success; 226if (errorCode != SocketError.Success) 284catch (TargetInvocationException ex) when (ex.InnerException is SocketException se && se.SocketErrorCode == SocketError.OperationNotSupported)
System\Net\Sockets\SocketAsyncContext.Unix.cs (107)
130public SocketError ErrorCode; 248ErrorCode = SocketError.OperationAborted; 314ErrorCode = SocketError.OperationAborted; 359public Action<int, Memory<byte>, SocketFlags, SocketError>? Callback { get; set; } 382SocketError ec = ErrorCode; 410SocketError ec = ErrorCode; 443public Action<int, Memory<byte>, SocketFlags, SocketError>? Callback { get; set; } 464ErrorCode = SocketError.Success; 479if (completed && ErrorCode == SocketError.Success) 494SocketError ec = ErrorCode; 514if (completed && ErrorCode == SocketError.Success) 527SocketError ec = ErrorCode; 548if (completed && ErrorCode == SocketError.Success) 570public Action<int, Memory<byte>, SocketFlags, IPPacketInformation, SocketError>? Callback { get; set; } 575if (completed && ErrorCode == SocketError.Success) 600public Action<int, Memory<byte>, SocketFlags, IPPacketInformation, SocketError>? Callback { get; set; } 605if (completed && ErrorCode == SocketError.Success) 622public Action<IntPtr, Memory<byte>, SocketError>? Callback { get; set; } 627Debug.Assert(ErrorCode == SocketError.Success || AcceptedFileDescriptor == (IntPtr)(-1), $"Unexpected values: ErrorCode={ErrorCode}, AcceptedFileDescriptor={AcceptedFileDescriptor}"); 628if (ErrorCode == SocketError.Success) 640SocketError ec = ErrorCode; 660if (result && ErrorCode == SocketError.Success && Buffer.Length > 0) 662SocketError error = context.SendToAsync(Buffer, 0, Buffer.Length, SocketFlags.None, Memory<byte>.Empty, ref BytesTransferred, Callback!, default); 663if (error != SocketError.Success && error != SocketError.IOPending) 676SocketError ec = ErrorCode; 698public Action<long, SocketError>? Callback { get; set; } 1427operation.ErrorCode = SocketError.TimedOut; 1432private bool ShouldRetrySyncOperation(out SocketError errorCode) 1436errorCode = SocketError.Success; // Will be ignored 1441errorCode = SocketError.TimedOut; 1449public SocketError Accept(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd) 1453SocketError errorCode; 1458Debug.Assert(errorCode == SocketError.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}"); 1474public SocketError AcceptAsync(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd, Action<IntPtr, Memory<byte>, SocketError> callback, CancellationToken cancellationToken) 1481SocketError errorCode; 1486Debug.Assert(errorCode == SocketError.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}"); 1507return SocketError.IOPending; 1510public SocketError Connect(Memory<byte> socketAddress) 1519SocketError errorCode; 1539public SocketError ConnectAsync(Memory<byte> socketAddress, Action<int, Memory<byte>, SocketFlags, SocketError> callback, Memory<byte> buffer, out int sentBytes, CancellationToken cancellationToken) 1549SocketError errorCode; 1562if (errorCode == SocketError.Success && remains > 0) 1579if (operation.ErrorCode == SocketError.Success) 1586return SocketError.IOPending; 1589public SocketError Receive(Memory<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived) 1594public SocketError Receive(Span<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived) 1599public SocketError ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken) 1604public SocketError ReceiveFrom(Memory<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 1611SocketError errorCode; 1637public unsafe SocketError ReceiveFrom(Span<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 1642SocketError errorCode; 1671public SocketError ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken = default) 1675SocketError errorCode; 1700return SocketError.IOPending; 1703public 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) 1707SocketError errorCode; 1736return SocketError.IOPending; 1739public SocketError Receive(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesReceived) 1744public SocketError ReceiveAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 1749public SocketError ReceiveFrom(IList<ArraySegment<byte>> buffers, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 1756SocketError errorCode; 1781public 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) 1785SocketError errorCode; 1814return SocketError.IOPending; 1817public SocketError ReceiveMessageFrom( 1825SocketError errorCode; 1854public unsafe SocketError ReceiveMessageFrom( 1862SocketError errorCode; 1894public 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) 1898SocketError errorCode; 1930return SocketError.IOPending; 1933public SocketError Send(ReadOnlySpan<byte> buffer, SocketFlags flags, int timeout, out int bytesSent) => 1936public SocketError Send(byte[] buffer, int offset, int count, SocketFlags flags, int timeout, out int bytesSent) 1941public SocketError SendAsync(Memory<byte> buffer, int offset, int count, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken) 1947public SocketError SendTo(byte[] buffer, int offset, int count, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1954SocketError errorCode; 1979public unsafe SocketError SendTo(ReadOnlySpan<byte> buffer, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1986SocketError errorCode; 2015public 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) 2019SocketError errorCode; 2045return SocketError.IOPending; 2048public SocketError Send(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesSent) 2053public SocketError SendAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 2058public SocketError SendTo(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 2067SocketError errorCode; 2092public SocketError SendToAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 2099SocketError errorCode; 2125return SocketError.IOPending; 2128public SocketError SendFile(SafeFileHandle fileHandle, long offset, long count, int timeout, out long bytesSent) 2135SocketError errorCode; 2158public SocketError SendFileAsync(SafeFileHandle fileHandle, long offset, long count, out long bytesSent, Action<long, SocketError> callback, CancellationToken cancellationToken = default) 2163SocketError errorCode; 2186return SocketError.IOPending;
System\Net\Sockets\SocketAsyncEventArgs.cs (22)
55private SocketError _socketError; 287public SocketError SocketError 431internal void SetResults(SocketError socketError, int bytesTransferred, SocketFlags flags) 447_socketError = SocketError.Success; 460_socketError = SocketError.OperationAborted; 464_socketError = SocketError.SocketError; 627internal void FinishOperationSyncFailure(SocketError socketError, int bytesTransferred, SocketFlags flags) 659internal void FinishOperationAsyncFailure(SocketError socketError, int bytesTransferred, SocketFlags flags) 725SocketError lastError = SocketError.NoData; 789if (internalArgs.SocketError == SocketError.Success) 797lastError = SocketError.OperationAborted; 817caughtException = new SocketException((int)SocketError.OperationAborted); 840(caughtException is SocketException se && se.SocketErrorCode == SocketError.OperationAborted)) 854SetResults(SocketError.Success, internalArgs.BytesTransferred, internalArgs.SocketFlags); 901SetResults(SocketError.Success, bytesTransferred, flags); 908SocketError socketError; 917if (socketError == SocketError.Success) 940if (socketError == SocketError.Success) 1045private void FinishOperationSync(SocketError socketError, int bytesTransferred, SocketFlags flags) 1047Debug.Assert(socketError != SocketError.IOPending); 1049if (socketError == SocketError.Success)
System\Net\Sockets\SocketAsyncEventArgs.Unix.cs (44)
16private Action<int, Memory<byte>, SocketFlags, SocketError>? _transferCompletionCallback; 26private void AcceptCompletionCallback(IntPtr acceptedFileDescriptor, Memory<byte> socketAddress, SocketError socketError) 33private void CompleteAcceptOperation(IntPtr acceptedFileDescriptor, Memory<byte> socketAddress, SocketError socketError) 36if (socketError == SocketError.Success) 46internal SocketError DoOperationAccept(Socket _ /*socket*/, SafeSocketHandle handle, SafeSocketHandle? acceptHandle, CancellationToken cancellationToken) 58SocketError socketError = handle.AsyncContext.AcceptAsync(_acceptBuffer!, out int socketAddressLen, out acceptedFd, AcceptCompletionCallback, cancellationToken); 60if (socketError != SocketError.IOPending) 69private void ConnectCompletionCallback(int bytesTransferred, Memory<byte> socketAddress, SocketFlags receivedFlags, SocketError socketError) 74internal SocketError DoOperationConnectEx(Socket _ /*socket*/, SafeSocketHandle handle, CancellationToken cancellationToken) 76SocketError socketError = handle.AsyncContext.ConnectAsync(_socketAddress!.Buffer, ConnectCompletionCallback, _buffer.Slice(_offset, _count), out int sentBytes, cancellationToken); 77if (socketError != SocketError.IOPending) 84internal SocketError DoOperationConnect(SafeSocketHandle handle, CancellationToken cancellationToken) 86SocketError socketError = handle.AsyncContext.ConnectAsync(_socketAddress!.Buffer, ConnectCompletionCallback, Memory<byte>.Empty, out int _, cancellationToken); 87if (socketError != SocketError.IOPending) 94internal SocketError DoOperationDisconnect(Socket socket, SafeSocketHandle handle, CancellationToken _ /*cancellationToken*/) 96SocketError socketError = SocketPal.Disconnect(socket, handle, _disconnectReuseSocket); 101private Action<int, Memory<byte>, SocketFlags, SocketError> TransferCompletionCallback => 104private void TransferCompletionCallbackCore(int bytesTransferred, Memory<byte> socketAddress, SocketFlags receivedFlags, SocketError socketError) 117internal SocketError DoOperationReceive(SafeSocketHandle handle, CancellationToken cancellationToken) 124SocketError errorCode; 144if (errorCode != SocketError.IOPending) 153internal SocketError DoOperationReceiveFrom(SafeSocketHandle handle, CancellationToken cancellationToken) 159SocketError errorCode; 171if (errorCode != SocketError.IOPending) 180private void ReceiveMessageFromCompletionCallback(int bytesTransferred, Memory<byte> socketAddress, SocketFlags receivedFlags, IPPacketInformation ipPacketInformation, SocketError errorCode) 196internal SocketError DoOperationReceiveMessageFrom(Socket socket, SafeSocketHandle handle, CancellationToken cancellationToken) 209SocketError socketError = handle.AsyncContext.ReceiveMessageFromAsync(_buffer.Slice(_offset, _count), _bufferListInternal, _socketFlags, _socketAddress.Buffer, out socketAddressSize, isIPv4, isIPv6, out bytesReceived, out receivedFlags, out ipPacketInformation, ReceiveMessageFromCompletionCallback, cancellationToken); 210if (socketError != SocketError.IOPending) 219internal SocketError DoOperationSend(SafeSocketHandle handle, CancellationToken cancellationToken) 225SocketError errorCode; 235if (errorCode != SocketError.IOPending) 244internal SocketError DoOperationSendPackets(Socket socket, SafeSocketHandle _1 /*handle*/, CancellationToken cancellationToken) 290if (error == SocketError.Success) 300return SocketError.IOPending; 303internal SocketError DoOperationSendTo(SafeSocketHandle handle, CancellationToken cancellationToken) 309SocketError errorCode; 319if (errorCode != SocketError.IOPending) 345private SocketError FinishOperationAccept(SocketAddress remoteSocketAddress) 367return SocketError.Success; 370private static SocketError FinishOperationConnect() 373return SocketError.Success; 385private void CompletionCallback(int bytesTransferred, SocketFlags flags, SocketError socketError) 387if (socketError == SocketError.Success) 395socketError = SocketError.OperationAborted;
System\Net\Sockets\SocketPal.Unix.cs (160)
30public static SocketError GetSocketErrorForErrorCode(Interop.Error errorCode) 59public static unsafe SocketError CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, out SafeSocketHandle socket) 64SocketError errorCode; 70errorCode = SocketError.Success; 626public static unsafe bool TryCompleteAccept(SafeSocketHandle socket, Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd, out SocketError errorCode) 641errorCode = SocketError.OperationAborted; 652errorCode = SocketError.Success; 665errorCode = SocketError.Success; 669public static bool TryStartConnect(SafeSocketHandle socket, Memory<byte> socketAddress, out SocketError errorCode) => TryStartConnect(socket, socketAddress, out errorCode, Span<byte>.Empty, false, out int _ ); 671public static unsafe bool TryStartConnect(SafeSocketHandle socket, Memory<byte> socketAddress, out SocketError errorCode, Span<byte> data, bool tfo, out int sent) 678errorCode = SocketError.IsConnected; 699errorCode = SocketError.Success; 709errorCode = SocketError.Success; 713public static unsafe bool TryCompleteConnect(SafeSocketHandle socket, out SocketError errorCode) 741errorCode = SocketError.OperationAborted; 748errorCode = SocketError.SocketError; 754errorCode = SocketError.Success; 759errorCode = SocketError.Success; 767public 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) => 770public 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) => 773public static unsafe bool TryCompleteReceive(SafeSocketHandle socket, Span<byte> buffer, SocketFlags flags, out int bytesReceived, out SocketError errorCode) 808errorCode = SocketError.Success; 820errorCode = SocketError.Success; 827errorCode = SocketError.OperationAborted; 832public 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) 876errorCode = SocketError.Success; 889errorCode = SocketError.Success; 898errorCode = SocketError.OperationAborted; 903public static 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) 922errorCode = SocketError.Success; 934errorCode = SocketError.Success; 944errorCode = SocketError.OperationAborted; 949public 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) 955public static bool TryCompleteSendTo(SafeSocketHandle socket, ReadOnlySpan<byte> buffer, SocketFlags flags, ReadOnlySpan<byte> socketAddress, ref int bytesSent, out SocketError errorCode) 961public 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) 967public 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) 995errorCode = SocketError.OperationAborted; 1007errorCode = successfulSend ? SocketError.Success : SocketError.WouldBlock; 1019errorCode = SocketError.Success; 1029errorCode = SocketError.TimedOut; 1036public static bool TryCompleteSendFile(SafeSocketHandle socket, SafeFileHandle handle, ref long offset, ref long count, ref long bytesSent, out SocketError errorCode) 1050errorCode = SocketError.OperationAborted; 1062errorCode = SocketError.Success; 1068errorCode = SocketError.Success; 1074public static SocketError SetBlocking(SafeSocketHandle handle, bool shouldBlock, out bool willBlock) 1080return SocketError.Success; 1083public static unsafe SocketError GetSockName(SafeSocketHandle handle, byte* buffer, int* nameLen) 1086return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1089public static unsafe SocketError GetAvailable(SafeSocketHandle handle, out int available) 1095return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1098public static unsafe SocketError GetAtOutOfBandMark(SafeSocketHandle handle, out int atOutOfBandMark) 1104return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1107public static unsafe SocketError GetPeerName(SafeSocketHandle handle, Span<byte> buffer, ref int nameLen) 1117return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1120public static SocketError Bind(SafeSocketHandle handle, ProtocolType socketProtocolType, ReadOnlySpan<byte> buffer) 1124return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1127public static SocketError Listen(SafeSocketHandle handle, int backlog) 1130return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1133public static SocketError Accept(SafeSocketHandle listenSocket, Memory<byte> socketAddress, out int socketAddressLen, out SafeSocketHandle socket) 1138SocketError errorCode; 1147errorCode = SocketError.WouldBlock; 1158public static SocketError Connect(SafeSocketHandle handle, Memory<byte> socketAddress) 1165SocketError errorCode; 1174return SocketError.WouldBlock; 1178public static SocketError Send(SafeSocketHandle handle, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out int bytesTransferred) 1189SocketError errorCode; 1194public static SocketError Send(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, out int bytesTransferred) 1202SocketError errorCode; 1207public static SocketError Send(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out int bytesTransferred) 1215SocketError errorCode; 1220public static SocketError SendFile(SafeSocketHandle handle, SafeFileHandle fileHandle) 1231SocketError errorCode; 1233return completed ? errorCode : SocketError.WouldBlock; 1236public static SocketError SendTo(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, Memory<byte> socketAddress, out int bytesTransferred) 1244SocketError errorCode; 1249public static SocketError SendTo(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, SocketFlags socketFlags, Memory<byte> socketAddress, out int bytesTransferred) 1257SocketError errorCode; 1262public static SocketError Receive(SafeSocketHandle handle, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out int bytesTransferred) 1264SocketError errorCode; 1273errorCode = SocketError.WouldBlock; 1280public static SocketError Receive(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, out int bytesTransferred) 1287SocketError errorCode; 1289return completed ? errorCode : SocketError.WouldBlock; 1292public static SocketError Receive(SafeSocketHandle handle, Span<byte> buffer, SocketFlags socketFlags, out int bytesTransferred) 1299SocketError errorCode; 1301return completed ? errorCode : SocketError.WouldBlock; 1304public 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) 1311SocketError errorCode; 1320errorCode = SocketError.WouldBlock; 1330public static SocketError ReceiveMessageFrom(Socket socket, SafeSocketHandle handle, Span<byte> buffer, ref SocketFlags socketFlags, SocketAddress socketAddress, out SocketAddress receiveAddress, out IPPacketInformation ipPacketInformation, out int bytesTransferred) 1337SocketError errorCode; 1346errorCode = SocketError.WouldBlock; 1355public static SocketError ReceiveFrom(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesTransferred) 1362SocketError errorCode; 1364return completed ? errorCode : SocketError.WouldBlock; 1367public static SocketError ReceiveFrom(SafeSocketHandle handle, Span<byte> buffer, SocketFlags socketFlags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesTransferred) 1374SocketError errorCode; 1376return completed ? errorCode : SocketError.WouldBlock; 1379public static SocketError WindowsIoctl(SafeSocketHandle handle, int ioControlCode, byte[]? _ /*optionInValue*/, byte[]? optionOutValue, out int optionLength) 1401return SocketError.Fault; 1405SocketError error = ioControlCode == FIONREAD ? 1408if (error == SocketError.Success) 1421private static SocketError GetErrorAndTrackSetting(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, Interop.Error err) 1426return SocketError.Success; 1431public static unsafe SocketError SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue) 1502public static unsafe SocketError SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) 1511public static unsafe SocketError SetRawSockOpt(SafeSocketHandle handle, int optionLevel, int optionName, ReadOnlySpan<byte> optionValue) 1525return SocketError.Success; 1532public static unsafe SocketError SetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, MulticastOption optionValue) 1555public static unsafe SocketError SetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, IPv6MulticastOption optionValue) 1572public static unsafe SocketError SetLingerOption(SafeSocketHandle handle, LingerOption optionValue) 1600public static unsafe SocketError GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, out int optionValue) 1607return SocketError.Success; 1612return SocketError.Success; 1621return getErrorError == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(getErrorError); 1640return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1643public static unsafe SocketError GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue, ref int optionLength) 1656SocketError returnError = GetSockOpt(handle, optionLevel, optionName, out outError); 1657if (returnError == SocketError.Success) 1678return SocketError.Success; 1684public static unsafe SocketError GetRawSockOpt(SafeSocketHandle handle, int optionLevel, int optionName, Span<byte> optionValue, ref int optionLength) 1696return SocketError.Success; 1703public static unsafe SocketError GetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out MulticastOption? optionValue) 1725return SocketError.Success; 1728public static unsafe SocketError GetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out IPv6MulticastOption? optionValue) 1745return SocketError.Success; 1748public static unsafe SocketError GetLingerOption(SafeSocketHandle handle, out LingerOption? optionValue) 1759return SocketError.Success; 1762public static SocketError Poll(SafeSocketHandle handle, int microseconds, SelectMode mode, out bool status) 1789return SocketError.Success; 1792public static unsafe SocketError Select(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds) 1835private static SocketError SelectViaSelect(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds) 1884return (SocketError)0; 1932private static unsafe SocketError SelectViaPoll( 1980return SocketError.Success; 2049public static SocketError Shutdown(SafeSocketHandle handle, bool isConnected, bool isDisconnected, SocketShutdown how) 2055return SocketError.Success; 2064return SocketError.Success; 2070private static SocketError SendFileAsync(SafeSocketHandle handle, SafeFileHandle fileHandle, long offset, long count, CancellationToken cancellationToken, Action<long, SocketError> callback) 2073SocketError socketError = handle.AsyncContext.SendFileAsync(fileHandle, offset, count, out bytesSent, callback, cancellationToken); 2074if (socketError == SocketError.Success) 2076callback(bytesSent, SocketError.Success); 2082Socket socket, TransmitFileOptions options, SendPacketsElement[] elements, SafeFileHandle[] fileHandles, CancellationToken cancellationToken, Action<long, SocketError> callback) 2084SocketError error = SocketError.Success; 2108var tcs = new TaskCompletionSource<SocketError>(); 2117if (error == SocketError.IOPending) 2121if (error != SocketError.Success) 2132if (error != SocketError.Success) 2147exc is ArgumentException ? SocketError.InvalidArgument : 2148exc is OperationCanceledException ? SocketError.OperationAborted : 2149SocketError.SocketError; 2157internal static SocketError Disconnect(Socket socket, SafeSocketHandle handle, bool reuseSocket) 2164SocketError.Success; 2191SocketError errorCode = GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Error, out int optionValue); 2192if (errorCode != SocketError.Success) 2197success = (SocketError)optionValue == SocketError.Success;
System\Net\Sockets\SocketsTelemetry.cs (25)
51private void ConnectFailed(SocketError error, string? exceptionMessage) 75private void AcceptFailed(SocketError error, string? exceptionMessage) 145public void AfterConnect(SocketError error, Activity? activity, string? exceptionMessage = null) 152if (error != SocketError.Success) 161if (error == SocketError.Success) 193public void AfterAccept(SocketError error, string? exceptionMessage = null) 195if (error == SocketError.Success) 234private static string GetErrorType(SocketError socketError) => socketError switch 239SocketError.NetworkDown => "network_down", 240SocketError.AddressAlreadyInUse => "address_already_in_use", 241SocketError.Interrupted => "interrupted", 242SocketError.InProgress => "in_progress", 243SocketError.AlreadyInProgress => "already_in_progress", 244SocketError.AddressNotAvailable => "address_not_available", 245SocketError.AddressFamilyNotSupported => "address_family_not_supported", 246SocketError.ConnectionRefused => "connection_refused", 247SocketError.Fault => "fault", 248SocketError.InvalidArgument => "invalid_argument", 249SocketError.IsConnected => "is_connected", 250SocketError.NetworkUnreachable => "network_unreachable", 251SocketError.HostUnreachable => "host_unreachable", 252SocketError.NoBufferSpaceAvailable => "no_buffer_space_available", 253SocketError.TimedOut => "timed_out", 254SocketError.AccessDenied => "access_denied", 255SocketError.ProtocolType => "protocol_type",
System\Net\Sockets\UDPClient.cs (4)
427throw new SocketException((int)SocketError.OperationNotSupported); 447throw new SocketException((int)SocketError.OperationNotSupported); 515throw new SocketException((int)SocketError.OperationNotSupported); 795throw new SocketException((int)SocketError.NotConnected);
System.ServiceModel.Http (5)
System\ServiceModel\Channels\HttpChannelHelpers.cs (5)
125SocketError socketErrorCode = innerSocketException.SocketErrorCode; 128case SocketError.TryAgain: 129case SocketError.NoRecovery: 130case SocketError.NoData: 131case SocketError.HostNotFound:
System.ServiceModel.NetTcp (8)
System\ServiceModel\Channels\SocketAwaitableEventArgs.cs (8)
41var error = SocketError; 43return error == SocketError.Success 58var error = SocketError; 60return error == SocketError.Success 83if (SocketError != SocketError.Success) 95if (SocketError != SocketError.Success) 101protected static SocketException CreateException(SocketError e) 109SocketError == SocketError.Success ? ValueTaskSourceStatus.Succeeded :
System.ServiceModel.UnixDomainSocket (8)
System\ServiceModel\Channels\SocketAwaitableEventArgs.cs (8)
41var error = SocketError; 43return error == SocketError.Success 58var error = SocketError; 60return error == SocketError.Success 83if (SocketError != SocketError.Success) 95if (SocketError != SocketError.Success) 101protected static SocketException CreateException(SocketError e) 109SocketError == SocketError.Success ? ValueTaskSourceStatus.Succeeded :