SocketException Class
System.Net.Sockets
Inheritance: Object → Exception → SystemException → SerializableException → SocketException
- Assembly:
- System.dll
- Declared in:
- System.Net.Sockets
Syntax
public class SocketException : SystemException
Remarks
The SocketException
class represents an error that occurred when performing a Windows Sockets operation.
This exception is thrown by the Socket
class and related classes when a socket operation fails.
The ErrorCode
property provides the specific error code for the socket operation that failed.
You can use this error code to look up more detailed information about the error in the Windows Sockets documentation.
Constructors
-
SocketException()
Initializes a new instance of the
SocketException
class with default values. -
SocketException(int errorCode)
Initializes a new instance of the
SocketException
class with the specified Windows Sockets error code.Parameters:
errorCode
: An int that specifies the Windows Sockets error code.
-
SocketException(string message)
Initializes a new instance of the
SocketException
class with a specified error message.Parameters:
message
: A string that describes the error.
-
SocketException(string message, Exception innerException)
Initializes a new instance of the
SocketException
class with a specified error message and a reference to the inner exception that is the cause of this exception.Parameters:
message
: The error message that explains the reason for the exception.innerException
: The exception that is the cause of the current exception. IfinnerException
is notnull
, the current exception is raised in acatch
block that handles the inner exception.
Properties
-
ErrorCode
Gets the Windows Sockets error code associated with the exception.
Type: int
-
Message
Gets a message that describes the current exception.
Inherited from: Exception
-
SocketErrorMessage
Gets the socket error message string associated with the current exception.
Type: string