SocketError Enum

System.Net.Sockets

Overview

Specifies error codes that are returned by socket operations.

The SocketError enumeration defines a set of standard errors that can occur during socket operations. These errors are typically returned as the result of a socket method call, indicating the nature of any failure.

Understanding these error codes is crucial for robust network programming, allowing you to handle specific network issues gracefully and implement appropriate recovery strategies.

Members

Success

(0)

The operation completed successfully.

ConnectionAborted

(10053)

A connection must be made before calling this operation.

ConnectionRefused

(10061)

A connection attempt failed because the connected party did not respond.

ConnectionReset

(10054)

An existing connection was forcibly closed by the remote host.

HostNotFound

(11001)

The requested name is valid, but no data of the requested type was found.

InvalidArgument

(10022)

An invalid argument was supplied.

NetworkDown

(10050)

The network is unreachable.

NetworkUnreachable

(10051)

An attempt to access a network location was unsuccessful.

NoBufferSpaceAvailable

(10055)

An operation on a socket could not be performed because the system lacked sufficient buffer space or because another transac- tion or process was deadlocked.

OperationAborted

(10004)

An overlapped operation was aborted due to being canceled.

ProcessLimitExceeded

(10067)

A Windows Sockets implementation error.

Shutdown

(10058)

An operation cannot be performed on a closed socket.

TimedWait

(10060)

A connection attempt failed because the connected party did not properly respond after a period of time.

SocketError

(11001)

An unspecified socket error occurred.

SystemNotReady

(10091)

The underlying network system is not ready to issue or accept socket operations.

Syntax

public enum SocketError

The SocketError enumeration is a value type that represents specific socket error codes. The values are typically obtained from the SocketException.ErrorCode property.

namespace System.Net.Sockets
{
   public enum SocketError
   {
      Success = 0,
      ConnectionAborted = 10053,
      ConnectionRefused = 10061,
      ConnectionReset = 10054,
      HostNotFound = 11001,
      InvalidArgument = 10022,
      NetworkDown = 10050,
      NetworkUnreachable = 10051,
      NoBufferSpaceAvailable = 10055,
      OperationAborted = 10004,
      ProcessLimitExceeded = 10067,
      Shutdown = 10058,
      TimedWait = 10060,
      SocketError = 11001,
      SystemNotReady = 10091,
      TryAgain = 10056
   }
}

See Also