1063 references to SocketError
aspire (3)
Backchannel\AuxiliaryBackchannelMonitor.cs (2)
530catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionRefused) 712/// A connect that fails with <see cref="SocketError.ConnectionRefused"/> cannot distinguish an
src\Shared\SocketExceptionHelpers.cs (1)
18return exception is IOException { InnerException: SocketException { SocketErrorCode: SocketError.ConnectionReset } };
Aspire.Cli.Tests (8)
Backchannel\AuxiliaryBackchannelMonitorTests.cs (1)
464ConnectAsyncCallback = _ => ValueTask.FromException<Socket>(new SocketException((int)SocketError.ConnectionRefused))
Commands\RunCommandTests.cs (1)
2415new SocketException((int)SocketError.ConnectionRefused)));
Commands\TelemetryFollowTests.cs (1)
34? new IOException("Connection reset.", new SocketException((int)SocketError.ConnectionReset))
DotNet\DotNetCliRunnerTests.cs (3)
1550ConnectAsyncCallback = (_, _) => throw new SocketException((int)SocketError.ConnectionRefused) 1590ConnectAsyncCallback = (_, _) => throw new SocketException((int)SocketError.ConnectionRefused) 1632ConnectAsyncCallback = (_, _) => throw new SocketException((int)SocketError.ConnectionRefused)
Projects\GuestAppHostProjectTests.cs (2)
1996ConnectAsyncCallback = (_, _) => throw new SocketException((int)SocketError.ConnectionRefused) 2024ConnectAsyncCallback = (_, _) => throw new SocketException((int)SocketError.ConnectionRefused)
Aspire.Dashboard (1)
DashboardWebApplication.cs (1)
1208if (current is SocketException { SocketErrorCode: SocketError.AddressAlreadyInUse })
Aspire.Dashboard.Tests (1)
Integration\ServerRetryHelper.cs (1)
171catch (SocketException ex) when (ex.SocketErrorCode == SocketError.AddressAlreadyInUse)
Aspire.Hosting (1)
src\Shared\SocketExceptionHelpers.cs (1)
18return exception is IOException { InnerException: SocketException { SocketErrorCode: SocketError.ConnectionReset } };
Aspire.Hosting.Native.Core.Tests (1)
NativeSocketIsolationTests.cs (1)
219throw new SocketException((int)SocketError.ConnectionReset);
Aspire.Hosting.Native.Server (2)
Dashboard\DcpDashboard.cs (1)
88SocketException { SocketErrorCode: SocketError.ConnectionRefused })
src\Shared\DcpConnectionMaterial.cs (1)
141InnerException: SocketException { SocketErrorCode: SocketError.ConnectionRefused } or AuthenticationException
Aspire.Hosting.Tests (8)
Utils\SocketExceptionHelpersTests.cs (8)
13[InlineData(SocketError.ConnectionReset, true)] 14[InlineData(SocketError.ConnectionAborted, false)] 15[InlineData(SocketError.ConnectionRefused, false)] 16[InlineData(SocketError.NetworkReset, false)] 17[InlineData(SocketError.Shutdown, false)] 18[InlineData(SocketError.TimedOut, false)] 19public void IsConnectionReset_OnlyMatchesResetSocketError(SocketError socketError, bool expected) 29var socketException = new SocketException((int)SocketError.ConnectionReset);
Aspire.TerminalHost (4)
TerminalHostControlListener.cs (4)
324private static bool IsTransientAcceptError(SocketError code) => code switch 328SocketError.TryAgain => true, 329SocketError.WouldBlock => true, 331SocketError.Interrupted => true,
dotnet-svcutil-lib (2)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\CoreClrSocketConnection.cs (2)
481if (_asyncWriteEventArgs.SocketError == SocketError.Success) 720if (_asyncReadEventArgs.SocketError == SocketError.Success)
Infrastructure.Tests (1)
PowerShellScripts\DownloadNativeArchivesTests.cs (1)
39Assert.Equal(SocketError.AddressAlreadyInUse, ex.SocketErrorCode);
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)
426private static bool IsConnectionResetError(SocketError errorCode) 428return errorCode == SocketError.ConnectionReset || 429errorCode == SocketError.Shutdown || 430(errorCode == SocketError.ConnectionAborted && OperatingSystem.IsWindows()); 433private static bool IsConnectionAbortError(SocketError errorCode) 436return errorCode == SocketError.OperationAborted || 437errorCode == SocketError.Interrupted || 438(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 (4)
HttpExceptionSummaryProvider.cs (4)
25private static readonly FrozenDictionary<SocketError, int> _socketErrorMap; 37var socketErrors = new Dictionary<SocketError, int>(); 39foreach (var socketError in Enum.GetValues<SocketError>())
Microsoft.Extensions.Diagnostics.ExceptionSummarization.Tests (5)
ExceptionSummarizerTests.cs (3)
22.Concat(Enum.GetNames(typeof(SocketError)).ToList()).ToList(); 185var exception = new Exception("test", new SocketException((int)SocketError.TimedOut)); 186var descriptionIndex = _httpDescriptions.FindIndex(x => x.Equals(SocketError.TimedOut.ToString()));
HttpExceptionSummaryProviderTests.cs (2)
22foreach (var socketError in Enum.GetValues(typeof(SocketError))) 92public void Describe_WithKnownSocketException_ReturnDetails(SocketError socketError)
Microsoft.Extensions.Diagnostics.Probes.Tests (1)
TcpEndpointProbesServiceTests.cs (1)
109if (e.SocketErrorCode == SocketError.ConnectionRefused)
Microsoft.NET.Build.Containers (3)
AuthRealmHandlerFactory.cs (3)
235HttpRequestError error = ex.SocketErrorCode is SocketError.HostNotFound or SocketError.NoData or SocketError.TryAgain
Microsoft.TestPlatform.CommunicationUtilities (2)
SocketCommunicationManager.cs (1)
376&& socketException.SocketErrorCode == SocketError.TimedOut)
TcpClientExtensions.cs (1)
73&& socketException.SocketErrorCode == SocketError.TimedOut)
netstandard (1)
netstandard.cs (1)
1271[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.Sockets.SocketError))]
System (1)
parent\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)
67case SocketError.AddressAlreadyInUse: 68case SocketError.AddressNotAvailable: 69case 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 (2)
System\Net\Managed\HttpEndPointListener.cs (1)
110Socket? accepted = args.SocketError == SocketError.Success ? args.AcceptSocket : null;
System\Net\Managed\ListenerAsyncResult.Managed.cs (1)
71_exception = new HttpListenerException((int)SocketError.OperationAborted, SR.net_listener_close);
System.Net.NameResolution (29)
System\Net\Dns.cs (10)
487exception = new SocketException((int)SocketError.HostNotFound); 519SocketError errorCode = NameResolutionPal.TryGetAddrInfo(hostName, justAddresses, addressFamily, out string? newHostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode); 521if (errorCode != SocketError.Success) 568catch (SocketException ex) when (addressFamily == AddressFamily.InterNetworkV6 && ex.SocketErrorCode == SocketError.HostNotFound) 601SocketError errorCode; 606if (errorCode != SocketError.Success) 634if (errorCode != SocketError.Success) 865catch (SocketException ex) when (family == AddressFamily.InterNetworkV6 && ex.SocketErrorCode == SocketError.HostNotFound) 878catch (SocketException ex) when (family == AddressFamily.InterNetworkV6 && ex.SocketErrorCode == SocketError.HostNotFound) 997private static SocketException CreateException(SocketError error, int nativeError) =>
System\Net\DnsResolverPal.Managed.cs (1)
519lastException = ex.SocketErrorCode == SocketError.TimedOut
System\Net\DnsSocket.cs (1)
114throw new SocketException((int)SocketError.TimedOut);
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\runtime\src\libraries\Common\src\System\Net\NetworkInformation\NetworkInformationException.cs (1)
44internal NetworkInformationException(SocketError socketError) : base((int)socketError)
System\Net\NetworkInformation\NetworkAddressChange.Unix.cs (1)
208catch (SocketException se) when (se.SocketErrorCode == SocketError.OperationAborted)
System.Net.Ping (101)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\LibraryImports.g.cs (3)
31internal static unsafe partial global::System.Net.Sockets.SocketError ReceiveSocketError(global::System.Runtime.InteropServices.SafeHandle socket, global::Interop.Sys.MessageHeader* messageHeader) 36global::System.Net.Sockets.SocketError __retVal = default; 57static extern unsafe global::System.Net.Sockets.SocketError __PInvoke(nint __socket_native, global::Interop.Sys.MessageHeader* __messageHeader_native);
src\runtime\src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReceiveSocketError.cs (1)
13internal static unsafe partial SocketError ReceiveSocketError(SafeHandle socket, MessageHeader* messageHeader);
src\runtime\src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
src\runtime\src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (88)
20internal static SocketError GetSocketErrorForNativeError(Interop.Error errno) => errno switch 22Interop.Error.EACCES => SocketError.AccessDenied, 23Interop.Error.EADDRINUSE => SocketError.AddressAlreadyInUse, 24Interop.Error.EADDRNOTAVAIL => SocketError.AddressNotAvailable, 25Interop.Error.EAFNOSUPPORT => SocketError.AddressFamilyNotSupported, 26Interop.Error.EAGAIN => SocketError.WouldBlock, 27Interop.Error.EALREADY => SocketError.AlreadyInProgress, 28Interop.Error.EBADF => SocketError.OperationAborted, 29Interop.Error.ECANCELED => SocketError.OperationAborted, 30Interop.Error.ECONNABORTED => SocketError.ConnectionAborted, 31Interop.Error.ECONNREFUSED => SocketError.ConnectionRefused, 32Interop.Error.ECONNRESET => SocketError.ConnectionReset, 33Interop.Error.EDESTADDRREQ => SocketError.DestinationAddressRequired, 34Interop.Error.EFAULT => SocketError.Fault, 35Interop.Error.EHOSTDOWN => SocketError.HostDown, 36Interop.Error.ENXIO => SocketError.HostNotFound, // not perfect, but closest match available 37Interop.Error.EHOSTUNREACH => SocketError.HostUnreachable, 38Interop.Error.EINPROGRESS => SocketError.InProgress, 39Interop.Error.EINTR => SocketError.Interrupted, 40Interop.Error.EINVAL => SocketError.InvalidArgument, 41Interop.Error.EISCONN => SocketError.IsConnected, 42Interop.Error.EMFILE => SocketError.TooManyOpenSockets, 43Interop.Error.EMSGSIZE => SocketError.MessageSize, 44Interop.Error.ENETDOWN => SocketError.NetworkDown, 45Interop.Error.ENETRESET => SocketError.NetworkReset, 46Interop.Error.ENETUNREACH => SocketError.NetworkUnreachable, 47Interop.Error.ENFILE => SocketError.TooManyOpenSockets, 48Interop.Error.ENOBUFS => SocketError.NoBufferSpaceAvailable, 49Interop.Error.ENODATA => SocketError.NoData, 50Interop.Error.ENOENT => SocketError.AddressNotAvailable, 51Interop.Error.ENOPROTOOPT => SocketError.ProtocolOption, 52Interop.Error.ENOTCONN => SocketError.NotConnected, 53Interop.Error.ENOTSOCK => SocketError.NotSocket, 54Interop.Error.ENOTSUP => SocketError.OperationNotSupported, 55Interop.Error.EPERM => SocketError.AccessDenied, 56Interop.Error.EPIPE => SocketError.Shutdown, 57Interop.Error.EPFNOSUPPORT => SocketError.ProtocolFamilyNotSupported, 58Interop.Error.EPROTONOSUPPORT => SocketError.ProtocolNotSupported, 59Interop.Error.EPROTOTYPE => SocketError.ProtocolType, 60Interop.Error.ESOCKTNOSUPPORT => SocketError.SocketNotSupported, 61Interop.Error.ESHUTDOWN => SocketError.Disconnecting, 62Interop.Error.SUCCESS => SocketError.Success, 63Interop.Error.ETIMEDOUT => SocketError.TimedOut, 64_ => SocketError.SocketError, // unknown native error, just treat it as a generic SocketError 67private static Interop.Error GetNativeErrorForSocketErrorHelper(SocketError error) => error switch 75SocketError.AccessDenied => Interop.Error.EACCES, // could also have been EPERM 76SocketError.AddressAlreadyInUse => Interop.Error.EADDRINUSE, 77SocketError.AddressNotAvailable => Interop.Error.EADDRNOTAVAIL, 78SocketError.AddressFamilyNotSupported => Interop.Error.EAFNOSUPPORT, 79SocketError.AlreadyInProgress => Interop.Error.EALREADY, 80SocketError.ConnectionAborted => Interop.Error.ECONNABORTED, 81SocketError.ConnectionRefused => Interop.Error.ECONNREFUSED, 82SocketError.ConnectionReset => Interop.Error.ECONNRESET, 83SocketError.DestinationAddressRequired => Interop.Error.EDESTADDRREQ, 84SocketError.Disconnecting => Interop.Error.ESHUTDOWN, 85SocketError.Fault => Interop.Error.EFAULT, 86SocketError.HostDown => Interop.Error.EHOSTDOWN, 87SocketError.HostNotFound => Interop.Error.EHOSTNOTFOUND, 88SocketError.HostUnreachable => Interop.Error.EHOSTUNREACH, 89SocketError.InProgress => Interop.Error.EINPROGRESS, 90SocketError.Interrupted => Interop.Error.EINTR, 91SocketError.InvalidArgument => Interop.Error.EINVAL, 92SocketError.IOPending => Interop.Error.EINPROGRESS, 93SocketError.IsConnected => Interop.Error.EISCONN, 94SocketError.MessageSize => Interop.Error.EMSGSIZE, 95SocketError.NetworkDown => Interop.Error.ENETDOWN, 96SocketError.NetworkReset => Interop.Error.ENETRESET, 97SocketError.NetworkUnreachable => Interop.Error.ENETUNREACH, 98SocketError.NoBufferSpaceAvailable => Interop.Error.ENOBUFS, 99SocketError.NoData => Interop.Error.ENODATA, 100SocketError.NotConnected => Interop.Error.ENOTCONN, 101SocketError.NotSocket => Interop.Error.ENOTSOCK, 102SocketError.OperationAborted => Interop.Error.ECANCELED, 103SocketError.OperationNotSupported => Interop.Error.ENOTSUP, 104SocketError.ProtocolFamilyNotSupported => Interop.Error.EPFNOSUPPORT, 105SocketError.ProtocolNotSupported => Interop.Error.EPROTONOSUPPORT, 106SocketError.ProtocolOption => Interop.Error.ENOPROTOOPT, 107SocketError.ProtocolType => Interop.Error.EPROTOTYPE, 108SocketError.Shutdown => Interop.Error.EPIPE, 109SocketError.SocketNotSupported => Interop.Error.ESOCKTNOSUPPORT, 110SocketError.Success => Interop.Error.SUCCESS, 111SocketError.TimedOut => Interop.Error.ETIMEDOUT, 112SocketError.TooManyOpenSockets => Interop.Error.ENFILE, // could also have been EMFILE 113SocketError.TryAgain => Interop.Error.EAGAIN, // not a perfect mapping, but better than nothing 114SocketError.WouldBlock => Interop.Error.EAGAIN, 115SocketError.SocketError => Interop.Error.ESOCKETERROR, 119internal static Interop.Error GetNativeErrorForSocketError(SocketError error) 130internal static bool TryGetNativeErrorForSocketError(SocketError error, out Interop.Error errno)
System\Net\NetworkInformation\Ping.RawSocket.cs (8)
278catch (SocketException ex) when (ex.SocketErrorCode == SocketError.TimedOut) 281catch (SocketException ex) when (ex.SocketErrorCode == SocketError.MessageSize) 285catch (SocketException ex) when (ex.SocketErrorCode == SocketError.HostUnreachable) 304SocketError result; 311if (result == SocketError.Success && header.SocketAddressLen > 0) 363catch (SocketException ex) when (ex.SocketErrorCode == SocketError.TimedOut) 366catch (SocketException ex) when (ex.SocketErrorCode == SocketError.MessageSize) 373catch (SocketException ex) when (ex.SocketErrorCode == SocketError.HostUnreachable)
System.Net.Primitives (100)
src\runtime\src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
src\runtime\src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (88)
20internal static SocketError GetSocketErrorForNativeError(Interop.Error errno) => errno switch 22Interop.Error.EACCES => SocketError.AccessDenied, 23Interop.Error.EADDRINUSE => SocketError.AddressAlreadyInUse, 24Interop.Error.EADDRNOTAVAIL => SocketError.AddressNotAvailable, 25Interop.Error.EAFNOSUPPORT => SocketError.AddressFamilyNotSupported, 26Interop.Error.EAGAIN => SocketError.WouldBlock, 27Interop.Error.EALREADY => SocketError.AlreadyInProgress, 28Interop.Error.EBADF => SocketError.OperationAborted, 29Interop.Error.ECANCELED => SocketError.OperationAborted, 30Interop.Error.ECONNABORTED => SocketError.ConnectionAborted, 31Interop.Error.ECONNREFUSED => SocketError.ConnectionRefused, 32Interop.Error.ECONNRESET => SocketError.ConnectionReset, 33Interop.Error.EDESTADDRREQ => SocketError.DestinationAddressRequired, 34Interop.Error.EFAULT => SocketError.Fault, 35Interop.Error.EHOSTDOWN => SocketError.HostDown, 36Interop.Error.ENXIO => SocketError.HostNotFound, // not perfect, but closest match available 37Interop.Error.EHOSTUNREACH => SocketError.HostUnreachable, 38Interop.Error.EINPROGRESS => SocketError.InProgress, 39Interop.Error.EINTR => SocketError.Interrupted, 40Interop.Error.EINVAL => SocketError.InvalidArgument, 41Interop.Error.EISCONN => SocketError.IsConnected, 42Interop.Error.EMFILE => SocketError.TooManyOpenSockets, 43Interop.Error.EMSGSIZE => SocketError.MessageSize, 44Interop.Error.ENETDOWN => SocketError.NetworkDown, 45Interop.Error.ENETRESET => SocketError.NetworkReset, 46Interop.Error.ENETUNREACH => SocketError.NetworkUnreachable, 47Interop.Error.ENFILE => SocketError.TooManyOpenSockets, 48Interop.Error.ENOBUFS => SocketError.NoBufferSpaceAvailable, 49Interop.Error.ENODATA => SocketError.NoData, 50Interop.Error.ENOENT => SocketError.AddressNotAvailable, 51Interop.Error.ENOPROTOOPT => SocketError.ProtocolOption, 52Interop.Error.ENOTCONN => SocketError.NotConnected, 53Interop.Error.ENOTSOCK => SocketError.NotSocket, 54Interop.Error.ENOTSUP => SocketError.OperationNotSupported, 55Interop.Error.EPERM => SocketError.AccessDenied, 56Interop.Error.EPIPE => SocketError.Shutdown, 57Interop.Error.EPFNOSUPPORT => SocketError.ProtocolFamilyNotSupported, 58Interop.Error.EPROTONOSUPPORT => SocketError.ProtocolNotSupported, 59Interop.Error.EPROTOTYPE => SocketError.ProtocolType, 60Interop.Error.ESOCKTNOSUPPORT => SocketError.SocketNotSupported, 61Interop.Error.ESHUTDOWN => SocketError.Disconnecting, 62Interop.Error.SUCCESS => SocketError.Success, 63Interop.Error.ETIMEDOUT => SocketError.TimedOut, 64_ => SocketError.SocketError, // unknown native error, just treat it as a generic SocketError 67private static Interop.Error GetNativeErrorForSocketErrorHelper(SocketError error) => error switch 75SocketError.AccessDenied => Interop.Error.EACCES, // could also have been EPERM 76SocketError.AddressAlreadyInUse => Interop.Error.EADDRINUSE, 77SocketError.AddressNotAvailable => Interop.Error.EADDRNOTAVAIL, 78SocketError.AddressFamilyNotSupported => Interop.Error.EAFNOSUPPORT, 79SocketError.AlreadyInProgress => Interop.Error.EALREADY, 80SocketError.ConnectionAborted => Interop.Error.ECONNABORTED, 81SocketError.ConnectionRefused => Interop.Error.ECONNREFUSED, 82SocketError.ConnectionReset => Interop.Error.ECONNRESET, 83SocketError.DestinationAddressRequired => Interop.Error.EDESTADDRREQ, 84SocketError.Disconnecting => Interop.Error.ESHUTDOWN, 85SocketError.Fault => Interop.Error.EFAULT, 86SocketError.HostDown => Interop.Error.EHOSTDOWN, 87SocketError.HostNotFound => Interop.Error.EHOSTNOTFOUND, 88SocketError.HostUnreachable => Interop.Error.EHOSTUNREACH, 89SocketError.InProgress => Interop.Error.EINPROGRESS, 90SocketError.Interrupted => Interop.Error.EINTR, 91SocketError.InvalidArgument => Interop.Error.EINVAL, 92SocketError.IOPending => Interop.Error.EINPROGRESS, 93SocketError.IsConnected => Interop.Error.EISCONN, 94SocketError.MessageSize => Interop.Error.EMSGSIZE, 95SocketError.NetworkDown => Interop.Error.ENETDOWN, 96SocketError.NetworkReset => Interop.Error.ENETRESET, 97SocketError.NetworkUnreachable => Interop.Error.ENETUNREACH, 98SocketError.NoBufferSpaceAvailable => Interop.Error.ENOBUFS, 99SocketError.NoData => Interop.Error.ENODATA, 100SocketError.NotConnected => Interop.Error.ENOTCONN, 101SocketError.NotSocket => Interop.Error.ENOTSOCK, 102SocketError.OperationAborted => Interop.Error.ECANCELED, 103SocketError.OperationNotSupported => Interop.Error.ENOTSUP, 104SocketError.ProtocolFamilyNotSupported => Interop.Error.EPFNOSUPPORT, 105SocketError.ProtocolNotSupported => Interop.Error.EPROTONOSUPPORT, 106SocketError.ProtocolOption => Interop.Error.ENOPROTOOPT, 107SocketError.ProtocolType => Interop.Error.EPROTOTYPE, 108SocketError.Shutdown => Interop.Error.EPIPE, 109SocketError.SocketNotSupported => Interop.Error.ESOCKTNOSUPPORT, 110SocketError.Success => Interop.Error.SUCCESS, 111SocketError.TimedOut => Interop.Error.ETIMEDOUT, 112SocketError.TooManyOpenSockets => Interop.Error.ENFILE, // could also have been EMFILE 113SocketError.TryAgain => Interop.Error.EAGAIN, // not a perfect mapping, but better than nothing 114SocketError.WouldBlock => Interop.Error.EAGAIN, 115SocketError.SocketError => Interop.Error.ESOCKETERROR, 119internal static Interop.Error GetNativeErrorForSocketError(SocketError error) 130internal static bool TryGetNativeErrorForSocketError(SocketError error, out Interop.Error errno)
System\Net\IPAddress.cs (2)
773private void ThrowSocketOperationNotSupported() => throw new SocketException(SocketError.OperationNotSupported, SR.Format(SR.net_SocketException_OperationNotSupported, AddressFamily)); 776private static void ThrowSocketOperationNotSupportedReadOnly() => throw new SocketException(SocketError.OperationNotSupported, SR.net_SocketException_OperationNotSupported_ReadOnlyIPAddress);
System\Net\IPAddressParser.cs (1)
59throw 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\runtime\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)
920sEx.SocketErrorCode == SocketError.TimedOut) 939if (se.SocketErrorCode == SocketError.HostNotFound)
System\Net\WebException.cs (2)
115case SocketError.NoData: 116case SocketError.HostNotFound:
System.Net.Security (20)
System\Net\Security\TlsOperationStatus.cs (1)
24/// <see cref="System.Net.Sockets.SocketError.WouldBlock"/> mid-write; retry the
System\Net\Security\TlsSession.cs (19)
2073private bool TryDrainPendingToSocket(out SocketError lastError) 2075lastError = SocketError.Success; 2081out SocketError err); 2129if (!TryDrainPendingToSocket(out SocketError drainErr)) 2131if (drainErr == SocketError.WouldBlock) 2158out SocketError sendErr); 2164if (sendErr == SocketError.WouldBlock) 2185out SocketError recvErr); 2191if (recvErr == SocketError.WouldBlock) 2282out SocketError recvErr); 2288if (recvErr == SocketError.WouldBlock) 2324if (!TryDrainPendingToSocket(out SocketError drainErr)) 2326if (drainErr == SocketError.WouldBlock) 2361out SocketError sendErr); 2367if (sendErr == SocketError.WouldBlock) 2414if (!TryDrainPendingToSocket(out SocketError leftoverErr)) 2416if (leftoverErr == SocketError.WouldBlock) 2436out SocketError sendErr); 2442if (sendErr == SocketError.WouldBlock)
System.Net.Sockets (700)
src\runtime\src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
29throw new SocketException((int)SocketError.AddressFamilyNotSupported);
src\runtime\src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (88)
20internal static SocketError GetSocketErrorForNativeError(Interop.Error errno) => errno switch 22Interop.Error.EACCES => SocketError.AccessDenied, 23Interop.Error.EADDRINUSE => SocketError.AddressAlreadyInUse, 24Interop.Error.EADDRNOTAVAIL => SocketError.AddressNotAvailable, 25Interop.Error.EAFNOSUPPORT => SocketError.AddressFamilyNotSupported, 26Interop.Error.EAGAIN => SocketError.WouldBlock, 27Interop.Error.EALREADY => SocketError.AlreadyInProgress, 28Interop.Error.EBADF => SocketError.OperationAborted, 29Interop.Error.ECANCELED => SocketError.OperationAborted, 30Interop.Error.ECONNABORTED => SocketError.ConnectionAborted, 31Interop.Error.ECONNREFUSED => SocketError.ConnectionRefused, 32Interop.Error.ECONNRESET => SocketError.ConnectionReset, 33Interop.Error.EDESTADDRREQ => SocketError.DestinationAddressRequired, 34Interop.Error.EFAULT => SocketError.Fault, 35Interop.Error.EHOSTDOWN => SocketError.HostDown, 36Interop.Error.ENXIO => SocketError.HostNotFound, // not perfect, but closest match available 37Interop.Error.EHOSTUNREACH => SocketError.HostUnreachable, 38Interop.Error.EINPROGRESS => SocketError.InProgress, 39Interop.Error.EINTR => SocketError.Interrupted, 40Interop.Error.EINVAL => SocketError.InvalidArgument, 41Interop.Error.EISCONN => SocketError.IsConnected, 42Interop.Error.EMFILE => SocketError.TooManyOpenSockets, 43Interop.Error.EMSGSIZE => SocketError.MessageSize, 44Interop.Error.ENETDOWN => SocketError.NetworkDown, 45Interop.Error.ENETRESET => SocketError.NetworkReset, 46Interop.Error.ENETUNREACH => SocketError.NetworkUnreachable, 47Interop.Error.ENFILE => SocketError.TooManyOpenSockets, 48Interop.Error.ENOBUFS => SocketError.NoBufferSpaceAvailable, 49Interop.Error.ENODATA => SocketError.NoData, 50Interop.Error.ENOENT => SocketError.AddressNotAvailable, 51Interop.Error.ENOPROTOOPT => SocketError.ProtocolOption, 52Interop.Error.ENOTCONN => SocketError.NotConnected, 53Interop.Error.ENOTSOCK => SocketError.NotSocket, 54Interop.Error.ENOTSUP => SocketError.OperationNotSupported, 55Interop.Error.EPERM => SocketError.AccessDenied, 56Interop.Error.EPIPE => SocketError.Shutdown, 57Interop.Error.EPFNOSUPPORT => SocketError.ProtocolFamilyNotSupported, 58Interop.Error.EPROTONOSUPPORT => SocketError.ProtocolNotSupported, 59Interop.Error.EPROTOTYPE => SocketError.ProtocolType, 60Interop.Error.ESOCKTNOSUPPORT => SocketError.SocketNotSupported, 61Interop.Error.ESHUTDOWN => SocketError.Disconnecting, 62Interop.Error.SUCCESS => SocketError.Success, 63Interop.Error.ETIMEDOUT => SocketError.TimedOut, 64_ => SocketError.SocketError, // unknown native error, just treat it as a generic SocketError 67private static Interop.Error GetNativeErrorForSocketErrorHelper(SocketError error) => error switch 75SocketError.AccessDenied => Interop.Error.EACCES, // could also have been EPERM 76SocketError.AddressAlreadyInUse => Interop.Error.EADDRINUSE, 77SocketError.AddressNotAvailable => Interop.Error.EADDRNOTAVAIL, 78SocketError.AddressFamilyNotSupported => Interop.Error.EAFNOSUPPORT, 79SocketError.AlreadyInProgress => Interop.Error.EALREADY, 80SocketError.ConnectionAborted => Interop.Error.ECONNABORTED, 81SocketError.ConnectionRefused => Interop.Error.ECONNREFUSED, 82SocketError.ConnectionReset => Interop.Error.ECONNRESET, 83SocketError.DestinationAddressRequired => Interop.Error.EDESTADDRREQ, 84SocketError.Disconnecting => Interop.Error.ESHUTDOWN, 85SocketError.Fault => Interop.Error.EFAULT, 86SocketError.HostDown => Interop.Error.EHOSTDOWN, 87SocketError.HostNotFound => Interop.Error.EHOSTNOTFOUND, 88SocketError.HostUnreachable => Interop.Error.EHOSTUNREACH, 89SocketError.InProgress => Interop.Error.EINPROGRESS, 90SocketError.Interrupted => Interop.Error.EINTR, 91SocketError.InvalidArgument => Interop.Error.EINVAL, 92SocketError.IOPending => Interop.Error.EINPROGRESS, 93SocketError.IsConnected => Interop.Error.EISCONN, 94SocketError.MessageSize => Interop.Error.EMSGSIZE, 95SocketError.NetworkDown => Interop.Error.ENETDOWN, 96SocketError.NetworkReset => Interop.Error.ENETRESET, 97SocketError.NetworkUnreachable => Interop.Error.ENETUNREACH, 98SocketError.NoBufferSpaceAvailable => Interop.Error.ENOBUFS, 99SocketError.NoData => Interop.Error.ENODATA, 100SocketError.NotConnected => Interop.Error.ENOTCONN, 101SocketError.NotSocket => Interop.Error.ENOTSOCK, 102SocketError.OperationAborted => Interop.Error.ECANCELED, 103SocketError.OperationNotSupported => Interop.Error.ENOTSUP, 104SocketError.ProtocolFamilyNotSupported => Interop.Error.EPFNOSUPPORT, 105SocketError.ProtocolNotSupported => Interop.Error.EPROTONOSUPPORT, 106SocketError.ProtocolOption => Interop.Error.ENOPROTOOPT, 107SocketError.ProtocolType => Interop.Error.EPROTOTYPE, 108SocketError.Shutdown => Interop.Error.EPIPE, 109SocketError.SocketNotSupported => Interop.Error.ESOCKTNOSUPPORT, 110SocketError.Success => Interop.Error.SUCCESS, 111SocketError.TimedOut => Interop.Error.ETIMEDOUT, 112SocketError.TooManyOpenSockets => Interop.Error.ENFILE, // could also have been EMFILE 113SocketError.TryAgain => Interop.Error.EAGAIN, // not a perfect mapping, but better than nothing 114SocketError.WouldBlock => Interop.Error.EAGAIN, 115SocketError.SocketError => Interop.Error.ESOCKETERROR, 119internal static Interop.Error GetNativeErrorForSocketError(SocketError error) 130internal static bool TryGetNativeErrorForSocketError(SocketError error, out Interop.Error errno)
src\runtime\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 (1)
152ret = !OwnsHandle || DoCloseHandle(abortive) == SocketError.Success;
System\Net\Sockets\SafeSocketHandle.Unix.cs (4)
85internal void RegisterConnectResult(SocketError error) 89case SocketError.Success: 90case SocketError.WouldBlock: 248private 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) 146if (SocketPal.GetSockName(handle, bufferPtr, &bufferLength) != SocketError.Success) 194case SocketError.Success: 221case SocketError.InvalidArgument: 286SocketError errorCode = SocketPal.GetAvailable(_handle, out argp); 291if (errorCode != SocketError.Success) 324SocketError errorCode = SocketPal.GetSockName(_handle, ptr, &size); 325if (errorCode != SocketError.Success) 367SocketError errorCode = SocketPal.GetPeerName( 371if (errorCode != SocketError.Success) 427SocketError errorCode = InternalSetBlocking(value, out current); 429if (errorCode != SocketError.Success) 814UpdateStatusAfterSocketErrorAndThrowException(SocketError.InvalidArgument); 818SocketError errorCode = SocketPal.Bind( 824if (errorCode != SocketError.Success) 1023SocketError errorCode = SocketPal.Listen(_handle, backlog); 1026if (errorCode != SocketError.Success) 1064SocketError errorCode; 1077SocketsTelemetry.Log.AfterAccept(SocketError.Interrupted, ex.Message); 1082if (errorCode != SocketError.Success) 1093SocketsTelemetry.Log.AfterAccept(SocketError.Success); 1137SocketError errorCode; 1139if (errorCode != SocketError.Success) 1146public int Send(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode) 1164if (errorCode != SocketError.Success) 1188SocketError errorCode; 1190if (errorCode != SocketError.Success) 1197public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode) 1212if (errorCode != SocketError.Success) 1242int bytesTransferred = Send(buffer, socketFlags, out SocketError errorCode); 1243return errorCode == SocketError.Success ? 1248public int Send(ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out SocketError errorCode) 1258if (errorCode != SocketError.Success) 1372SocketError errorCode = SocketPal.SendTo(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1375if (errorCode != SocketError.Success) 1454SocketError errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1457if (errorCode != SocketError.Success) 1495SocketError errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1498if (errorCode != SocketError.Success) 1540SocketError errorCode; 1542if (errorCode != SocketError.Success) 1549public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode) 1563if (errorCode != SocketError.Success) 1587int bytesTransferred = Receive(buffer, socketFlags, out SocketError errorCode); 1588return errorCode == SocketError.Success ? 1593public int Receive(Span<byte> buffer, SocketFlags socketFlags, out SocketError errorCode) 1605if (errorCode != SocketError.Success) 1631SocketError errorCode; 1633if (errorCode != SocketError.Success) 1640public int Receive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode) 1661if (errorCode != SocketError.Success) 1700SocketError errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, offset, size, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred); 1704if (errorCode != SocketError.Success && errorCode != SocketError.MessageSize) 1711if (errorCode == SocketError.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived(); 1787SocketError errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred); 1791if (errorCode != SocketError.Success && errorCode != SocketError.MessageSize) 1798if (errorCode == SocketError.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived(); 1842SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred); 1847if (errorCode != SocketError.Success) 1853if (socketException.SocketErrorCode != SocketError.MessageSize) 1966SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred); 1971if (errorCode != SocketError.Success) 1977if (socketException.SocketErrorCode != SocketError.MessageSize) 2044SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, receivedAddress.Buffer, out int socketAddressSize, out bytesTransferred); 2047if (errorCode != SocketError.Success) 2075SocketError errorCode = SocketPal.WindowsIoctl(_handle, ioControlCode, optionInValue, optionOutValue, out realOptionLength); 2080if (errorCode != SocketError.Success) 2109SocketError errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue); 2114if (errorCode != SocketError.Success) 2187SocketError errorCode = SocketPal.SetRawSockOpt(_handle, optionLevel, optionName, optionValue); 2191if (errorCode != SocketError.Success) 2218SocketError errorCode = SocketPal.GetSockOpt( 2227if (errorCode != SocketError.Success) 2242SocketError errorCode = SocketPal.GetSockOpt( 2252if (errorCode != SocketError.Success) 2266SocketError errorCode = SocketPal.GetSockOpt( 2276if (errorCode != SocketError.Success) 2308SocketError errorCode = SocketPal.GetRawSockOpt(_handle, optionLevel, optionName, optionValue, ref realOptionLength); 2312if (errorCode != SocketError.Success) 2364SocketError errorCode = SocketPal.Poll(_handle, microSeconds, mode, out status); 2368if (errorCode != SocketError.Success) 2428SocketError errorCode = SocketPal.Select(checkRead, checkWrite, checkError, microSeconds); 2431if (errorCode != SocketError.Success) 2485SocketError errorCode; 2492if (errorCode != SocketError.Success) 2514public IAsyncResult? BeginSend(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2528errorCode = SocketError.Success; 2541public IAsyncResult? BeginSend(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2554errorCode = SocketError.Success; 2560public int EndSend(IAsyncResult asyncResult, out SocketError errorCode) => 2611public IAsyncResult? BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2625errorCode = SocketError.Success; 2637public IAsyncResult? BeginReceive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2650errorCode = SocketError.Success; 2656public int EndReceive(IAsyncResult asyncResult, out SocketError errorCode) => 2659private static int EndSendReceive(IAsyncResult asyncResult, out SocketError errorCode) 2669errorCode = SocketError.Success; 2829SocketError errorCode = SocketPal.Shutdown(_handle, _isConnected, _isDisconnected, how); 2834if (errorCode != SocketError.Success && errorCode != SocketError.NotSocket) 2876SocketError socketError; 2883SocketsTelemetry.Log.AfterAccept(SocketError.Interrupted, ex.Message); 2890return socketError == SocketError.IOPending; 2969SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message); 2979SocketError socketError = canUseConnectEx ? 2982pending = socketError == SocketError.IOPending; 2986SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message); 3069SocketError socketError; 3081return socketError == SocketError.IOPending; 3094SocketError socketError; 3106return socketError == SocketError.IOPending; 3155SocketError socketError; 3167bool pending = (socketError == SocketError.IOPending); 3203SocketError socketError; 3215return socketError == SocketError.IOPending; 3228SocketError socketError; 3240return socketError == SocketError.IOPending; 3261SocketError socketError; 3273return socketError == SocketError.IOPending; 3310SocketError socketError; 3330return socketError == SocketError.IOPending; 3381SocketError errorCode; 3388SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, activity, ex.Message); 3393if (errorCode != SocketError.Success) 3406SocketsTelemetry.Log.AfterConnect(SocketError.Success, activity); 3462SocketError errorCode; 3492if (errorCode != SocketError.Success) 3502if (errorCode != (SocketError)0) 3514if (errorCode != SocketError.Success || dataAvailable != 0) 3626UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError.ProtocolOption); 3636SocketError errorCode; 3653errorCode == SocketError.Success) 3664if (errorCode != SocketError.Success) 3672SocketError errorCode = SocketPal.SetMulticastOption(_handle, optionName, MR); 3677if (errorCode != SocketError.Success) 3686SocketError errorCode = SocketPal.SetIPv6MulticastOption(_handle, optionName, MR); 3691if (errorCode != SocketError.Success) 3701SocketError errorCode = SocketPal.SetLingerOption(_handle, lref); 3706if (errorCode != SocketError.Success) 3717SocketError errorCode = SocketPal.GetLingerOption(_handle, out lingerOption); 3722if (errorCode != SocketError.Success) 3733SocketError errorCode = SocketPal.GetMulticastOption(_handle, optionName, out multicastOption); 3738if (errorCode != SocketError.Success) 3750SocketError errorCode = SocketPal.GetIPv6MulticastOption(_handle, optionName, out multicastOption); 3755if (errorCode != SocketError.Success) 3765private SocketError InternalSetBlocking(bool desired, out bool current) 3770return SocketError.Success; 3775SocketError errorCode; 3782errorCode = SocketError.NotSocket; 3789if (errorCode == SocketError.Success) 3927private void UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, [CallerMemberName] string? callerName = null) 3930bool disconnectOnFailure = error != SocketError.ProtocolOption && 3931error != SocketError.OperationNotSupported; 3935private void UpdateStatusAfterSocketErrorAndThrowException(SocketError error, bool disconnectOnFailure = true, [CallerMemberName] string? callerName = null) 3952internal void UpdateStatusAfterSocketError(SocketError errorCode, bool disconnectOnFailure = true) 3958if (disconnectOnFailure && _isConnected && (_handle.IsInvalid || (errorCode != SocketError.WouldBlock && 3959errorCode != SocketError.IOPending && errorCode != SocketError.NoBufferSpaceAvailable && 3960errorCode != SocketError.TimedOut && errorCode != SocketError.OperationAborted))) 3968private bool CheckErrorAndUpdateStatus(SocketError errorCode) 3970if (errorCode == SocketError.Success || errorCode == SocketError.IOPending) 4020private void UpdateReceiveSocketErrorForDisposed(ref SocketError socketError, int bytesTransferred) 4027socketError = IsConnectionOriented ? SocketError.ConnectionAborted : SocketError.Interrupted; 4031private void UpdateSendSocketErrorForDisposed(ref SocketError socketError) 4035socketError = IsConnectionOriented ? SocketError.ConnectionAborted : SocketError.Interrupted; 4039private void UpdateConnectSocketErrorForDisposed(ref SocketError socketError) 4043socketError = SocketError.NotSocket; 4047private void UpdateAcceptSocketErrorForDisposed(ref SocketError socketError) 4051socketError = SocketError.Interrupted; 4064throw new SocketException((int)SocketError.IsConnected); 4085private static SocketError GetSocketErrorFromFaultedTask(Task t) 4091return SocketError.OperationAborted; 4098ObjectDisposedException => SocketError.OperationAborted, 4099OperationCanceledException => SocketError.OperationAborted, 4100_ => SocketError.SocketError
System\Net\Sockets\Socket.Tasks.cs (41)
162throw new SocketException((int)SocketError.IsConnected); 852if (saea.SocketError == SocketError.Success) 875SocketError error = saea.SocketError; 890if (error == SocketError.Success) 901private static Exception GetException(SocketError error, bool wrapExceptionsInIOExceptions = false) 1030SocketError error = SocketError; 1036return error == SocketError.Success ? 1052SocketError error = SocketError; 1056return error == SocketError.Success ? 1071SocketError error = SocketError; 1075return error == SocketError.Success ? 1089SocketError error = SocketError; 1093return error == SocketError.Success ? 1110SocketError error = SocketError; 1114return error == SocketError.Success ? 1130SocketError error = SocketError; 1134return error == SocketError.Success ? 1147SocketError error = SocketError; 1151return error == SocketError.Success ? 1164SocketError error = SocketError; 1168return error == SocketError.Success ? 1182SocketError error = SocketError; 1186return error == SocketError.Success ? 1207SocketError error = SocketError; 1211return error == SocketError.Success ? 1224SocketError error = SocketError; 1228return error == SocketError.Success ? 1254SocketError error = SocketError; 1260if (error != SocketError.Success) 1274SocketError error = SocketError; 1279if (error != SocketError.Success) 1292SocketError error = SocketError; 1300if (error != SocketError.Success) 1314SocketError error = SocketError; 1321if (error != SocketError.Success) 1336SocketError error = SocketError; 1345if (error != SocketError.Success) 1355private void ThrowException(SocketError error, CancellationToken cancellationToken) 1360if (error is SocketError.OperationAborted or SocketError.ConnectionAborted) 1368private 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) 145return ReplaceHandle() == SocketError.Success; 148internal unsafe SocketError ReplaceHandle() 158SocketError errorCode = SocketPal.CreateSocket(_addressFamily, _socketType, _protocolType, out SafeSocketHandle newHandle); 163if (errorCode != SocketError.Success) 177return SocketError.Success; 192throw new SocketException((int)SocketError.InvalidArgument); 220SocketError errorCode = SocketError.Success; 241if (errorCode != SocketError.Success)
System\Net\Sockets\SocketAsyncContext.Unix.cs (99)
120public SocketError ErrorCode; 148ErrorCode = SocketError.OperationAborted; 169public Action<int, Memory<byte>, SocketFlags, SocketError>? Callback { get; set; } 192SocketError ec = ErrorCode; 220SocketError ec = ErrorCode; 253public Action<int, Memory<byte>, SocketFlags, SocketError>? Callback { get; set; } 275ErrorCode = SocketError.Success; 290if (completed && ErrorCode == SocketError.Success) 305SocketError ec = ErrorCode; 325if (completed && ErrorCode == SocketError.Success) 338SocketError ec = ErrorCode; 359if (completed && ErrorCode == SocketError.Success) 381public Action<int, Memory<byte>, SocketFlags, IPPacketInformation, SocketError>? Callback { get; set; } 386if (completed && ErrorCode == SocketError.Success) 411public Action<int, Memory<byte>, SocketFlags, IPPacketInformation, SocketError>? Callback { get; set; } 416if (completed && ErrorCode == SocketError.Success) 433public Action<IntPtr, Memory<byte>, SocketError>? Callback { get; set; } 438Debug.Assert(ErrorCode == SocketError.Success || AcceptedFileDescriptor == (IntPtr)(-1), $"Unexpected values: ErrorCode={ErrorCode}, AcceptedFileDescriptor={AcceptedFileDescriptor}"); 439if (ErrorCode == SocketError.Success) 451SocketError ec = ErrorCode; 477if (!result || ErrorCode != SocketError.Success || Buffer.Length == 0) 503SocketError ec = ErrorCode; 522public Action<long, SocketError>? Callback { get; set; } 638operation.ErrorCode = SocketError.TimedOut; 642operation.ErrorCode = SocketError.OperationAborted; 646private bool ShouldRetrySyncOperation(out SocketError errorCode) 650errorCode = SocketError.Success; // Will be ignored 655errorCode = SocketError.TimedOut; 659public SocketError Accept(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd) 663SocketError errorCode; 668Debug.Assert(errorCode == SocketError.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}"); 684public SocketError AcceptAsync(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd, Action<IntPtr, Memory<byte>, SocketError> callback, CancellationToken cancellationToken) 691SocketError errorCode; 696Debug.Assert(errorCode == SocketError.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}"); 722public SocketError Connect(Memory<byte> socketAddress) 731SocketError errorCode; 751public SocketError ConnectAsync(Memory<byte> socketAddress, Action<int, Memory<byte>, SocketFlags, SocketError> callback, Memory<byte> buffer, out int sentBytes, CancellationToken cancellationToken) 761SocketError errorCode; 774if (errorCode == SocketError.Success && remains > 0) 780Action<int, Memory<byte>, SocketFlags, SocketError> connectCallback = callback; 789if (remains == 0 || errorCode != SocketError.IOPending) 821public SocketError Receive(Memory<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived) 826public SocketError Receive(Span<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived) 831public SocketError ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken) 836public SocketError ReceiveFrom(Memory<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 843SocketError errorCode; 869public unsafe SocketError ReceiveFrom(Span<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 874SocketError errorCode; 903public SocketError ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken = default) 907SocketError errorCode; 937public 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) 941SocketError errorCode; 975public SocketError Receive(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesReceived) 980public SocketError ReceiveAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 985public SocketError ReceiveFrom(IList<ArraySegment<byte>> buffers, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 992SocketError errorCode; 1017public 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) 1021SocketError errorCode; 1055public SocketError ReceiveMessageFrom( 1063SocketError errorCode; 1092public unsafe SocketError ReceiveMessageFrom( 1100SocketError errorCode; 1132public 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) 1136SocketError errorCode; 1174public SocketError Send(ReadOnlySpan<byte> buffer, SocketFlags flags, int timeout, out int bytesSent) => 1177public SocketError Send(byte[] buffer, int offset, int count, SocketFlags flags, int timeout, out int bytesSent) 1182public SocketError SendAsync(Memory<byte> buffer, int offset, int count, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken) 1188public SocketError SendTo(byte[] buffer, int offset, int count, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1195SocketError errorCode; 1220public unsafe SocketError SendTo(ReadOnlySpan<byte> buffer, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1227SocketError errorCode; 1256public 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) 1260SocketError errorCode; 1291public SocketError Send(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesSent) 1296public SocketError SendAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 1301public SocketError SendTo(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1310SocketError errorCode; 1335public SocketError SendToAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 1342SocketError errorCode; 1373public SocketError SendFile(SafeFileHandle fileHandle, long offset, long count, int timeout, out long bytesSent) 1380SocketError errorCode; 1403public SocketError SendFileAsync(SafeFileHandle fileHandle, long offset, long count, out long bytesSent, Action<long, SocketError> callback, CancellationToken cancellationToken = default) 1408SocketError errorCode; 1437private static SocketError GetSocketErrorForNonCompleted(AsyncResult result) 1440return result == AsyncResult.Pending ? SocketError.IOPending : SocketError.OperationAborted;
System\Net\Sockets\SocketAsyncEventArgs.cs (25)
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; 631internal void FinishOperationSyncFailure(SocketError socketError, int bytesTransferred, SocketFlags flags) 663internal void FinishOperationAsyncFailure(SocketError socketError, int bytesTransferred, SocketFlags flags) 748SocketError lastError = SocketError.NoData; 816if (internalArgs.SocketError == SocketError.Success) 824lastError = SocketError.OperationAborted; 844caughtException = new SocketException((int)SocketError.OperationAborted); 883(caughtException is SocketException se && se.SocketErrorCode == SocketError.OperationAborted)) 897SetResults(SocketError.Success, internalArgs.BytesTransferred, internalArgs.SocketFlags); 955public void SetResults(Socket? socket, SocketError socketError, int bytesTransferred, SocketFlags flags, Exception? exception) 960if (socketError == SocketError.Success && exception == null) 966_saea.SetResults(SocketError.Success, bytesTransferred, flags); 998SetResults(SocketError.Success, bytesTransferred, flags); 1005SocketError socketError; 1014if (socketError == SocketError.Success) 1041if (socketError == SocketError.Success) 1146private void FinishOperationSync(SocketError socketError, int bytesTransferred, SocketFlags flags) 1148Debug.Assert(socketError != SocketError.IOPending); 1150if (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 (162)
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) => 774private static unsafe bool TryCompleteZeroByteReceiveWasi(SafeSocketHandle socket, out SocketError errorCode) 789errorCode = SocketError.Success; 793public static unsafe bool TryCompleteReceive(SafeSocketHandle socket, Span<byte> buffer, SocketFlags flags, out int bytesReceived, out SocketError errorCode) 834errorCode = SocketError.Success; 846errorCode = SocketError.Success; 853errorCode = SocketError.OperationAborted; 858public 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) 910errorCode = SocketError.Success; 923errorCode = SocketError.Success; 932errorCode = SocketError.OperationAborted; 937public 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) 956errorCode = SocketError.Success; 968errorCode = SocketError.Success; 978errorCode = SocketError.OperationAborted; 983public 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) 989public static bool TryCompleteSendTo(SafeSocketHandle socket, ReadOnlySpan<byte> buffer, SocketFlags flags, ReadOnlySpan<byte> socketAddress, ref int bytesSent, out SocketError errorCode) 995public 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) 1001public 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) 1029errorCode = SocketError.OperationAborted; 1041errorCode = successfulSend ? SocketError.Success : SocketError.WouldBlock; 1053errorCode = SocketError.Success; 1063errorCode = SocketError.TimedOut; 1070public static bool TryCompleteSendFile(SafeSocketHandle socket, SafeFileHandle handle, ref long offset, ref long count, ref long bytesSent, out SocketError errorCode) 1084errorCode = SocketError.OperationAborted; 1096errorCode = SocketError.Success; 1102errorCode = SocketError.Success; 1108public static SocketError SetBlocking(SafeSocketHandle handle, bool shouldBlock, out bool willBlock) 1114return SocketError.Success; 1117public static unsafe SocketError GetSockName(SafeSocketHandle handle, byte* buffer, int* nameLen) 1120return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1123public static unsafe SocketError GetAvailable(SafeSocketHandle handle, out int available) 1129return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1132public static unsafe SocketError GetAtOutOfBandMark(SafeSocketHandle handle, out int atOutOfBandMark) 1138return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1141public static unsafe SocketError GetPeerName(SafeSocketHandle handle, Span<byte> buffer, ref int nameLen) 1151return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1154public static SocketError Bind(SafeSocketHandle handle, ProtocolType socketProtocolType, ReadOnlySpan<byte> buffer) 1158return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1161public static SocketError Listen(SafeSocketHandle handle, int backlog) 1164return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1167public static SocketError Accept(SafeSocketHandle listenSocket, Memory<byte> socketAddress, out int socketAddressLen, out SafeSocketHandle socket) 1172SocketError errorCode; 1181errorCode = SocketError.WouldBlock; 1192public static SocketError Connect(SafeSocketHandle handle, Memory<byte> socketAddress) 1199SocketError errorCode; 1208return SocketError.WouldBlock; 1212public static SocketError Send(SafeSocketHandle handle, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out int bytesTransferred) 1223SocketError errorCode; 1228public static SocketError Send(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, out int bytesTransferred) 1236SocketError errorCode; 1241public static SocketError Send(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out int bytesTransferred) 1249SocketError errorCode; 1254public static SocketError SendFile(SafeSocketHandle handle, SafeFileHandle fileHandle) 1265SocketError errorCode; 1267return completed ? errorCode : SocketError.WouldBlock; 1270public static SocketError SendTo(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, Memory<byte> socketAddress, out int bytesTransferred) 1278SocketError errorCode; 1283public static SocketError SendTo(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, SocketFlags socketFlags, Memory<byte> socketAddress, out int bytesTransferred) 1291SocketError errorCode; 1296public static SocketError Receive(SafeSocketHandle handle, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out int bytesTransferred) 1298SocketError errorCode; 1307errorCode = SocketError.WouldBlock; 1314public static SocketError Receive(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, out int bytesTransferred) 1321SocketError errorCode; 1323return completed ? errorCode : SocketError.WouldBlock; 1326public static SocketError Receive(SafeSocketHandle handle, Span<byte> buffer, SocketFlags socketFlags, out int bytesTransferred) 1333SocketError errorCode; 1335return completed ? errorCode : SocketError.WouldBlock; 1338public 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) 1345SocketError errorCode; 1354errorCode = SocketError.WouldBlock; 1364public static SocketError ReceiveMessageFrom(Socket socket, SafeSocketHandle handle, Span<byte> buffer, ref SocketFlags socketFlags, SocketAddress socketAddress, out SocketAddress receiveAddress, out IPPacketInformation ipPacketInformation, out int bytesTransferred) 1371SocketError errorCode; 1380errorCode = SocketError.WouldBlock; 1389public static SocketError ReceiveFrom(SafeSocketHandle handle, byte[] buffer, int offset, int count, SocketFlags socketFlags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesTransferred) 1396SocketError errorCode; 1398return completed ? errorCode : SocketError.WouldBlock; 1401public static SocketError ReceiveFrom(SafeSocketHandle handle, Span<byte> buffer, SocketFlags socketFlags, Memory<byte> socketAddress, out int socketAddressLen, out int bytesTransferred) 1408SocketError errorCode; 1410return completed ? errorCode : SocketError.WouldBlock; 1413public static SocketError WindowsIoctl(SafeSocketHandle handle, int ioControlCode, byte[]? _ /*optionInValue*/, byte[]? optionOutValue, out int optionLength) 1435return SocketError.Fault; 1439SocketError error = ioControlCode == FIONREAD ? 1442if (error == SocketError.Success) 1455private static SocketError GetErrorAndTrackSetting(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, Interop.Error err) 1460return SocketError.Success; 1465public static unsafe SocketError SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue) 1536public static unsafe SocketError SetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue) 1545public static unsafe SocketError SetRawSockOpt(SafeSocketHandle handle, int optionLevel, int optionName, ReadOnlySpan<byte> optionValue) 1559return SocketError.Success; 1566public static unsafe SocketError SetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, MulticastOption optionValue) 1589public static unsafe SocketError SetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, IPv6MulticastOption optionValue) 1606public static unsafe SocketError SetLingerOption(SafeSocketHandle handle, LingerOption optionValue) 1634public static unsafe SocketError GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, out int optionValue) 1641return SocketError.Success; 1646return SocketError.Success; 1655return getErrorError == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(getErrorError); 1674return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err); 1677public static unsafe SocketError GetSockOpt(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName, byte[] optionValue, ref int optionLength) 1690SocketError returnError = GetSockOpt(handle, optionLevel, optionName, out outError); 1691if (returnError == SocketError.Success) 1712return SocketError.Success; 1718public static unsafe SocketError GetRawSockOpt(SafeSocketHandle handle, int optionLevel, int optionName, Span<byte> optionValue, ref int optionLength) 1730return SocketError.Success; 1737public static unsafe SocketError GetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out MulticastOption? optionValue) 1759return SocketError.Success; 1762public static unsafe SocketError GetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out IPv6MulticastOption? optionValue) 1779return SocketError.Success; 1782public static unsafe SocketError GetLingerOption(SafeSocketHandle handle, out LingerOption? optionValue) 1793return SocketError.Success; 1796public static SocketError Poll(SafeSocketHandle handle, int microseconds, SelectMode mode, out bool status) 1823return SocketError.Success; 1826public static unsafe SocketError Select(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds) 1869private static unsafe SocketError SelectViaSelect(IList? checkRead, IList? checkWrite, IList? checkError, int microseconds) 1918return (SocketError)0; 1966private static unsafe SocketError SelectViaPoll( 2014return SocketError.Success; 2083public static SocketError Shutdown(SafeSocketHandle handle, bool isConnected, bool isDisconnected, SocketShutdown how) 2089return SocketError.Success; 2098return SocketError.Success; 2104private static SocketError SendFileAsync(SafeSocketHandle handle, SafeFileHandle fileHandle, long offset, long count, CancellationToken cancellationToken, Action<long, SocketError> callback) 2107SocketError socketError = handle.AsyncContext.SendFileAsync(fileHandle, offset, count, out bytesSent, callback, cancellationToken); 2108if (socketError == SocketError.Success) 2110callback(bytesSent, SocketError.Success); 2116Socket socket, TransmitFileOptions options, SendPacketsElement[] elements, SafeFileHandle[] fileHandles, CancellationToken cancellationToken, Action<long, SocketError> callback) 2118SocketError error = SocketError.Success; 2142var tcs = new TaskCompletionSource<SocketError>(); 2151if (error == SocketError.IOPending) 2155if (error != SocketError.Success) 2166if (error != SocketError.Success) 2181exc is ArgumentException ? SocketError.InvalidArgument : 2182exc is OperationCanceledException ? SocketError.OperationAborted : 2183SocketError.SocketError; 2191internal static SocketError Disconnect(Socket socket, SafeSocketHandle handle, bool reuseSocket) 2198SocketError.Success; 2225SocketError errorCode = GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Error, out int optionValue); 2226if (errorCode != SocketError.Success) 2231success = (SocketError)optionValue == SocketError.Success;
System\Net\Sockets\SocketsTelemetry.cs (27)
51private void ConnectFailed(SocketError error, string? exceptionMessage) 75private void AcceptFailed(SocketError error, string? exceptionMessage) 145public void AfterConnect(SocketError error, Activity? activity, string? exceptionMessage = null) 155bool connectPending = error is SocketError.WouldBlock or SocketError.InProgress; 159if (error != SocketError.Success && !connectPending) 168if (error == SocketError.Success) 200public void AfterAccept(SocketError error, string? exceptionMessage = null) 202if (error == SocketError.Success) 241private static string GetErrorType(SocketError socketError) => socketError switch 246SocketError.NetworkDown => "network_down", 247SocketError.AddressAlreadyInUse => "address_already_in_use", 248SocketError.Interrupted => "interrupted", 249SocketError.InProgress => "in_progress", 250SocketError.AlreadyInProgress => "already_in_progress", 251SocketError.AddressNotAvailable => "address_not_available", 252SocketError.AddressFamilyNotSupported => "address_family_not_supported", 253SocketError.ConnectionRefused => "connection_refused", 254SocketError.Fault => "fault", 255SocketError.InvalidArgument => "invalid_argument", 256SocketError.IsConnected => "is_connected", 257SocketError.NetworkUnreachable => "network_unreachable", 258SocketError.HostUnreachable => "host_unreachable", 259SocketError.NoBufferSpaceAvailable => "no_buffer_space_available", 260SocketError.TimedOut => "timed_out", 261SocketError.AccessDenied => "access_denied", 262SocketError.ProtocolType => "protocol_type",
System\Net\Sockets\UDPClient.cs (4)
432throw new SocketException((int)SocketError.OperationNotSupported); 452throw new SocketException((int)SocketError.OperationNotSupported); 520throw new SocketException((int)SocketError.OperationNotSupported); 800throw 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 :