Namespace: System.Net.Sockets
SocketException Class
Represents an error that occurred when performing a blocking Socket operation.
Inheritance
System.Object
System.Exception
System.Net.Sockets.SocketException
Syntax
public class SocketException : Exception
Remarks
The SocketException class represents errors that occur during Socket operations. It provides an ErrorCode property that returns the specific Windows Sockets error code associated with the exception. You can use this error code to determine the exact cause of the Socket error.
When a Socket operation fails, a SocketException is thrown. You can catch this exception and examine its ErrorCode property to diagnose the problem.
Constructors
| Name | Description |
|---|---|
| SocketException() | Initializes a new instance of the SocketException class. |
| SocketException(Int32) | Initializes a new instance of the SocketException class with a specified error code. |
| SocketException(Int32, String) | Initializes a new instance of the SocketException class with a specified error code and message. |
| SocketException(SerializationInfo, StreamingContext) | Initializes a new instance of the SocketException class with serialized data. |
Properties
| Name | Description |
|---|---|
| ErrorCode | Gets the error code returned by the operating system. |
| Handle | Gets the native error handle. (Inherited from Exception) |
| HelpLink | Gets or sets a link to the help file that is associated with this exception. (Inherited from Exception) |
| InnerException | Gets a reference to the inner exception that is the cause of the current exception. (Inherited from Exception) |
| Message | Gets a message that describes the current exception. (Inherited from Exception) |
| StackTrace | Gets a string representation of the immediate frames of the call stack. (Inherited from Exception) |
| TargetSite | Gets the method that throws the current exception. (Inherited from Exception) |
Methods
| Name | Description |
|---|---|
| GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception) |
| ToString() | Returns a string representation of the current exception. (Inherited from Exception) |