1006 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)
420private static bool IsConnectionResetError(SocketError errorCode) 422return errorCode == SocketError.ConnectionReset || 423errorCode == SocketError.Shutdown || 424(errorCode == SocketError.ConnectionAborted && OperatingSystem.IsWindows()); 427private static bool IsConnectionAbortError(SocketError errorCode) 430return errorCode == SocketError.OperationAborted || 431errorCode == SocketError.Interrupted || 432(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)
399SocketError errorCode = NameResolutionPal.TryGetAddrInfo(hostName, justAddresses, addressFamily, out string? newHostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode); 401if (errorCode != SocketError.Success) 446SocketError errorCode; 451if (errorCode != SocketError.Success) 474if (errorCode != SocketError.Success) 740private static SocketException CreateException(SocketError error, int nativeError) =>
System\Net\NameResolutionPal.Unix.cs (13)
27private static SocketError GetSocketErrorForNativeError(int error) 32return SocketError.Success; 34return SocketError.TryAgain; 37return SocketError.InvalidArgument; 39return SocketError.NoRecovery; 41return SocketError.AddressFamilyNotSupported; 43return SocketError.HostNotFound; 48return SocketError.SocketError; 51return SocketError.SocketError; 130public static unsafe SocketError TryGetAddrInfo(string name, bool justAddresses, AddressFamily addressFamily, out string? hostName, out string[] aliases, out IPAddress[] addresses, out int nativeErrorCode) 151return SocketError.Success; 154public static unsafe string? TryGetNameInfo(IPAddress addr, out SocketError socketError, out int nativeErrorCode) 189return socketError == SocketError.Success ? Marshal.PtrToStringUTF8((IntPtr)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)
46internal 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 (103)
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 (1)
761private static void ThrowSocketOperationNotSupported() => throw new SocketException(SocketError.OperationNotSupported);
System\Net\IPAddressParser.cs (1)
45throw 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)
400throw 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.Sockets (702)
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)
29internal void RegisterConnectResult(SocketError error) 33case SocketError.Success: 34case SocketError.WouldBlock: 226private unsafe SocketError DoCloseHandle(bool abortive)
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) 1018SocketError errorCode = SocketPal.Listen(_handle, backlog); 1021if (errorCode != SocketError.Success) 1059SocketError errorCode; 1072SocketsTelemetry.Log.AfterAccept(SocketError.Interrupted, ex.Message); 1077if (errorCode != SocketError.Success) 1088SocketsTelemetry.Log.AfterAccept(SocketError.Success); 1130SocketError errorCode; 1132if (errorCode != SocketError.Success) 1139public int Send(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode) 1157if (errorCode != SocketError.Success) 1181SocketError errorCode; 1183if (errorCode != SocketError.Success) 1190public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode) 1205if (errorCode != SocketError.Success) 1235int bytesTransferred = Send(buffer, socketFlags, out SocketError errorCode); 1236return errorCode == SocketError.Success ? 1241public int Send(ReadOnlySpan<byte> buffer, SocketFlags socketFlags, out SocketError errorCode) 1251if (errorCode != SocketError.Success) 1358SocketError errorCode = SocketPal.SendTo(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1361if (errorCode != SocketError.Success) 1440SocketError errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1443if (errorCode != SocketError.Success) 1481SocketError errorCode = SocketPal.SendTo(_handle, buffer, socketFlags, socketAddress.Buffer.Slice(0, socketAddress.Size), out bytesTransferred); 1484if (errorCode != SocketError.Success) 1526SocketError errorCode; 1528if (errorCode != SocketError.Success) 1535public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode) 1549if (errorCode != SocketError.Success) 1573int bytesTransferred = Receive(buffer, socketFlags, out SocketError errorCode); 1574return errorCode == SocketError.Success ? 1579public int Receive(Span<byte> buffer, SocketFlags socketFlags, out SocketError errorCode) 1591if (errorCode != SocketError.Success) 1617SocketError errorCode; 1619if (errorCode != SocketError.Success) 1626public int Receive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode) 1647if (errorCode != SocketError.Success) 1686SocketError errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, offset, size, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred); 1690if (errorCode != SocketError.Success && errorCode != SocketError.MessageSize) 1697if (errorCode == SocketError.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived(); 1773SocketError errorCode = SocketPal.ReceiveMessageFrom(this, _handle, buffer, ref socketFlags, socketAddress, out receiveAddress, out ipPacketInformation, out bytesTransferred); 1777if (errorCode != SocketError.Success && errorCode != SocketError.MessageSize) 1784if (errorCode == SocketError.Success && SocketType == SocketType.Dgram) SocketsTelemetry.Log.DatagramReceived(); 1828SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, offset, size, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred); 1833if (errorCode != SocketError.Success) 1839if (socketException.SocketErrorCode != SocketError.MessageSize) 1952SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, socketAddress.Buffer, out int socketAddressLength, out bytesTransferred); 1957if (errorCode != SocketError.Success) 1963if (socketException.SocketErrorCode != SocketError.MessageSize) 2030SocketError errorCode = SocketPal.ReceiveFrom(_handle, buffer, socketFlags, receivedAddress.Buffer, out int socketAddressSize, out bytesTransferred); 2033if (errorCode != SocketError.Success) 2061SocketError errorCode = SocketPal.WindowsIoctl(_handle, ioControlCode, optionInValue, optionOutValue, out realOptionLength); 2066if (errorCode != SocketError.Success) 2095SocketError errorCode = SocketPal.SetSockOpt(_handle, optionLevel, optionName, optionValue); 2100if (errorCode != SocketError.Success) 2173SocketError errorCode = SocketPal.SetRawSockOpt(_handle, optionLevel, optionName, optionValue); 2177if (errorCode != SocketError.Success) 2204SocketError errorCode = SocketPal.GetSockOpt( 2213if (errorCode != SocketError.Success) 2228SocketError errorCode = SocketPal.GetSockOpt( 2238if (errorCode != SocketError.Success) 2252SocketError errorCode = SocketPal.GetSockOpt( 2262if (errorCode != SocketError.Success) 2294SocketError errorCode = SocketPal.GetRawSockOpt(_handle, optionLevel, optionName, optionValue, ref realOptionLength); 2298if (errorCode != SocketError.Success) 2350SocketError errorCode = SocketPal.Poll(_handle, microSeconds, mode, out status); 2354if (errorCode != SocketError.Success) 2414SocketError errorCode = SocketPal.Select(checkRead, checkWrite, checkError, microSeconds); 2417if (errorCode != SocketError.Success) 2471SocketError errorCode; 2478if (errorCode != SocketError.Success) 2500public IAsyncResult? BeginSend(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2514errorCode = SocketError.Success; 2527public IAsyncResult? BeginSend(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2540errorCode = SocketError.Success; 2546public int EndSend(IAsyncResult asyncResult, out SocketError errorCode) => 2597public IAsyncResult? BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2611errorCode = SocketError.Success; 2623public IAsyncResult? BeginReceive(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode, AsyncCallback? callback, object? state) 2636errorCode = SocketError.Success; 2642public int EndReceive(IAsyncResult asyncResult, out SocketError errorCode) => 2645private static int EndSendReceive(IAsyncResult asyncResult, out SocketError errorCode) 2655errorCode = SocketError.Success; 2815SocketError errorCode = SocketPal.Shutdown(_handle, _isConnected, _isDisconnected, how); 2820if (errorCode != SocketError.Success && errorCode != SocketError.NotSocket) 2862SocketError socketError; 2869SocketsTelemetry.Log.AfterAccept(SocketError.Interrupted, ex.Message); 2876return socketError == SocketError.IOPending; 2954SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message); 2964SocketError socketError = canUseConnectEx ? 2967pending = socketError == SocketError.IOPending; 2971SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message); 3047SocketError socketError; 3059return socketError == SocketError.IOPending; 3072SocketError socketError; 3084return socketError == SocketError.IOPending; 3128SocketError socketError; 3140bool pending = (socketError == SocketError.IOPending); 3176SocketError socketError; 3188return socketError == SocketError.IOPending; 3201SocketError socketError; 3213return socketError == SocketError.IOPending; 3234SocketError socketError; 3246return socketError == SocketError.IOPending; 3283SocketError socketError; 3303return socketError == SocketError.IOPending; 3354SocketError errorCode; 3361SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, activity, ex.Message); 3366if (errorCode != SocketError.Success) 3379SocketsTelemetry.Log.AfterConnect(SocketError.Success, activity); 3435SocketError errorCode; 3465if (errorCode != SocketError.Success) 3475if (errorCode != (SocketError)0) 3487if (errorCode != SocketError.Success || dataAvailable != 0) 3599UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError.ProtocolOption); 3609SocketError errorCode; 3626errorCode == SocketError.Success) 3637if (errorCode != SocketError.Success) 3645SocketError errorCode = SocketPal.SetMulticastOption(_handle, optionName, MR); 3650if (errorCode != SocketError.Success) 3659SocketError errorCode = SocketPal.SetIPv6MulticastOption(_handle, optionName, MR); 3664if (errorCode != SocketError.Success) 3674SocketError errorCode = SocketPal.SetLingerOption(_handle, lref); 3679if (errorCode != SocketError.Success) 3690SocketError errorCode = SocketPal.GetLingerOption(_handle, out lingerOption); 3695if (errorCode != SocketError.Success) 3706SocketError errorCode = SocketPal.GetMulticastOption(_handle, optionName, out multicastOption); 3711if (errorCode != SocketError.Success) 3723SocketError errorCode = SocketPal.GetIPv6MulticastOption(_handle, optionName, out multicastOption); 3728if (errorCode != SocketError.Success) 3738private SocketError InternalSetBlocking(bool desired, out bool current) 3743return SocketError.Success; 3748SocketError errorCode; 3755errorCode = SocketError.NotSocket; 3762if (errorCode == SocketError.Success) 3900private void UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, [CallerMemberName] string? callerName = null) 3903bool disconnectOnFailure = error != SocketError.ProtocolOption && 3904error != SocketError.OperationNotSupported; 3908private void UpdateStatusAfterSocketErrorAndThrowException(SocketError error, bool disconnectOnFailure = true, [CallerMemberName] string? callerName = null) 3925internal void UpdateStatusAfterSocketError(SocketError errorCode, bool disconnectOnFailure = true) 3931if (disconnectOnFailure && _isConnected && (_handle.IsInvalid || (errorCode != SocketError.WouldBlock && 3932errorCode != SocketError.IOPending && errorCode != SocketError.NoBufferSpaceAvailable && 3933errorCode != SocketError.TimedOut && errorCode != SocketError.OperationAborted))) 3941private bool CheckErrorAndUpdateStatus(SocketError errorCode) 3943if (errorCode == SocketError.Success || errorCode == SocketError.IOPending) 3993private void UpdateReceiveSocketErrorForDisposed(ref SocketError socketError, int bytesTransferred) 4000socketError = IsConnectionOriented ? SocketError.ConnectionAborted : SocketError.Interrupted; 4004private void UpdateSendSocketErrorForDisposed(ref SocketError socketError) 4008socketError = IsConnectionOriented ? SocketError.ConnectionAborted : SocketError.Interrupted; 4012private void UpdateConnectSocketErrorForDisposed(ref SocketError socketError) 4016socketError = SocketError.NotSocket; 4020private void UpdateAcceptSocketErrorForDisposed(ref SocketError socketError) 4024socketError = SocketError.Interrupted; 4037throw new SocketException((int)SocketError.IsConnected); 4058private static SocketError GetSocketErrorFromFaultedTask(Task t) 4064return SocketError.OperationAborted; 4071ObjectDisposedException => SocketError.OperationAborted, 4072OperationCanceledException => SocketError.OperationAborted, 4073_ => SocketError.SocketError
System\Net\Sockets\Socket.Tasks.cs (42)
121catch (SocketException se) when (se.SocketErrorCode == SocketError.OperationAborted) 184throw new SocketException((int)SocketError.IsConnected); 874if (saea.SocketError == SocketError.Success) 897SocketError error = saea.SocketError; 912if (error == SocketError.Success) 923private static Exception GetException(SocketError error, bool wrapExceptionsInIOExceptions = false) 1052SocketError error = SocketError; 1058return error == SocketError.Success ? 1074SocketError error = SocketError; 1078return error == SocketError.Success ? 1093SocketError error = SocketError; 1097return error == SocketError.Success ? 1111SocketError error = SocketError; 1115return error == SocketError.Success ? 1132SocketError error = SocketError; 1136return error == SocketError.Success ? 1152SocketError error = SocketError; 1156return error == SocketError.Success ? 1169SocketError error = SocketError; 1173return error == SocketError.Success ? 1186SocketError error = SocketError; 1190return error == SocketError.Success ? 1204SocketError error = SocketError; 1208return error == SocketError.Success ? 1228SocketError error = SocketError; 1232return error == SocketError.Success ? 1245SocketError error = SocketError; 1249return error == SocketError.Success ? 1275SocketError error = SocketError; 1281if (error != SocketError.Success) 1295SocketError error = SocketError; 1300if (error != SocketError.Success) 1313SocketError error = SocketError; 1321if (error != SocketError.Success) 1335SocketError error = SocketError; 1342if (error != SocketError.Success) 1357SocketError error = SocketError; 1366if (error != SocketError.Success) 1376private void ThrowException(SocketError error, CancellationToken cancellationToken) 1381if (error is SocketError.OperationAborted or SocketError.ConnectionAborted) 1389private Exception CreateException(SocketError error, bool forAsyncThrow = true)
System\Net\Sockets\Socket.Unix.cs (13)
71throw new SocketException((int)SocketError.NotSocket); 79throw new SocketException((int)SocketError.NotSocket); 122SocketError errorCode = ReplaceHandle(); 123if (errorCode != SocketError.Success) 131internal SocketError ReplaceHandle() 154SocketError errorCode = SocketPal.CreateSocket(_addressFamily, _socketType, _protocolType, out SafeSocketHandle newHandle); 159if (errorCode != SocketError.Success) 184return SocketError.Success; 199throw new SocketException((int)SocketError.InvalidArgument); 227SocketError errorCode = SocketError.Success; 248if (errorCode != SocketError.Success) 306catch (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; } 1422operation.ErrorCode = SocketError.TimedOut; 1427private bool ShouldRetrySyncOperation(out SocketError errorCode) 1431errorCode = SocketError.Success; // Will be ignored 1436errorCode = SocketError.TimedOut; 1444public SocketError Accept(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd) 1448SocketError errorCode; 1453Debug.Assert(errorCode == SocketError.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}"); 1469public SocketError AcceptAsync(Memory<byte> socketAddress, out int socketAddressLen, out IntPtr acceptedFd, Action<IntPtr, Memory<byte>, SocketError> callback, CancellationToken cancellationToken) 1476SocketError errorCode; 1481Debug.Assert(errorCode == SocketError.Success || acceptedFd == (IntPtr)(-1), $"Unexpected values: errorCode={errorCode}, acceptedFd={acceptedFd}"); 1502return SocketError.IOPending; 1505public SocketError Connect(Memory<byte> socketAddress) 1514SocketError errorCode; 1534public SocketError ConnectAsync(Memory<byte> socketAddress, Action<int, Memory<byte>, SocketFlags, SocketError> callback, Memory<byte> buffer, out int sentBytes) 1544SocketError errorCode; 1557if (errorCode == SocketError.Success && remains > 0) 1574if (operation.ErrorCode == SocketError.Success) 1581return SocketError.IOPending; 1584public SocketError Receive(Memory<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived) 1589public SocketError Receive(Span<byte> buffer, SocketFlags flags, int timeout, out int bytesReceived) 1594public SocketError ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken) 1599public unsafe SocketError ReceiveFrom(Memory<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 1606SocketError errorCode; 1632public unsafe SocketError ReceiveFrom(Span<byte> buffer, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 1637SocketError errorCode; 1666public SocketError ReceiveAsync(Memory<byte> buffer, SocketFlags flags, out int bytesReceived, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken = default) 1670SocketError errorCode; 1695return SocketError.IOPending; 1698public 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) 1702SocketError errorCode; 1731return SocketError.IOPending; 1734public SocketError Receive(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesReceived) 1739public SocketError ReceiveAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesReceived, out SocketFlags receivedFlags, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 1744public unsafe SocketError ReceiveFrom(IList<ArraySegment<byte>> buffers, ref SocketFlags flags, Memory<byte> socketAddress, out int socketAddressLen, int timeout, out int bytesReceived) 1751SocketError errorCode; 1776public 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) 1780SocketError errorCode; 1809return SocketError.IOPending; 1812public SocketError ReceiveMessageFrom( 1820SocketError errorCode; 1849public unsafe SocketError ReceiveMessageFrom( 1857SocketError errorCode; 1889public 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) 1893SocketError errorCode; 1925return SocketError.IOPending; 1928public SocketError Send(ReadOnlySpan<byte> buffer, SocketFlags flags, int timeout, out int bytesSent) => 1931public SocketError Send(byte[] buffer, int offset, int count, SocketFlags flags, int timeout, out int bytesSent) 1936public SocketError SendAsync(Memory<byte> buffer, int offset, int count, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback, CancellationToken cancellationToken) 1942public SocketError SendTo(byte[] buffer, int offset, int count, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1949SocketError errorCode; 1974public unsafe SocketError SendTo(ReadOnlySpan<byte> buffer, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 1981SocketError errorCode; 2010public 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) 2014SocketError errorCode; 2040return SocketError.IOPending; 2043public SocketError Send(IList<ArraySegment<byte>> buffers, SocketFlags flags, int timeout, out int bytesSent) 2048public SocketError SendAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 2053public SocketError SendTo(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, int timeout, out int bytesSent) 2062SocketError errorCode; 2087public SocketError SendToAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags, Memory<byte> socketAddress, out int bytesSent, Action<int, Memory<byte>, SocketFlags, SocketError> callback) 2094SocketError errorCode; 2120return SocketError.IOPending; 2123public SocketError SendFile(SafeFileHandle fileHandle, long offset, long count, int timeout, out long bytesSent) 2130SocketError errorCode; 2153public SocketError SendFileAsync(SafeFileHandle fileHandle, long offset, long count, out long bytesSent, Action<long, SocketError> callback, CancellationToken cancellationToken = default) 2158SocketError errorCode; 2181return 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) 717SocketError lastError = SocketError.NoData; 784if (internalArgs.SocketError == SocketError.Success) 792throw new SocketException((int)SocketError.OperationAborted); 804caughtException = new SocketException((int)SocketError.OperationAborted); 827(caughtException is SocketException se && se.SocketErrorCode == SocketError.OperationAborted)) 841SetResults(SocketError.Success, internalArgs.BytesTransferred, internalArgs.SocketFlags); 888SetResults(SocketError.Success, bytesTransferred, flags); 895SocketError socketError; 904if (socketError == SocketError.Success) 927if (socketError == SocketError.Success) 1032private void FinishOperationSync(SocketError socketError, int bytesTransferred, SocketFlags flags) 1034Debug.Assert(socketError != SocketError.IOPending); 1036if (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 unsafe 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 unsafe SocketError DoOperationConnectEx(Socket _ /*socket*/, SafeSocketHandle handle) 76SocketError socketError = handle.AsyncContext.ConnectAsync(_socketAddress!.Buffer, ConnectCompletionCallback, _buffer.Slice(_offset, _count), out int sentBytes); 77if (socketError != SocketError.IOPending) 84internal unsafe SocketError DoOperationConnect(SafeSocketHandle handle) 86SocketError socketError = handle.AsyncContext.ConnectAsync(_socketAddress!.Buffer, ConnectCompletionCallback, Memory<byte>.Empty, out int _); 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 unsafe SocketError DoOperationReceive(SafeSocketHandle handle, CancellationToken cancellationToken) 124SocketError errorCode; 144if (errorCode != SocketError.IOPending) 153internal unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe bool TryCompleteReceiveMessageFrom(SafeSocketHandle socket, Span<byte> buffer, IList<ArraySegment<byte>>? buffers, SocketFlags flags, Memory<byte> socketAddress, out int receivedSocketAddressLength, bool isIPv4, bool isIPv6, out int bytesReceived, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out SocketError errorCode) 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 unsafe 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 unsafe 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.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 :