Socket Constructor (SocketType, ProtocolType)
Initializes a new instance of the Socket class using the specified socket type and protocol.
Assembly: System (in System.dll)
Parameters
- socketType
-
Type:
System.Net.Sockets::SocketType
One of the SocketType values.
- protocolType
-
Type:
System.Net.Sockets::ProtocolType
One of the ProtocolType values.
| Exception | Condition |
|---|---|
| SocketException | The combination of socketType and protocolType results in an invalid socket. |
The socketType parameter specifies the type of the Socket class and the protocolType parameter specifies the protocol used by Socket. The two parameters are not independent. Often the Socket type is implicit in the protocol. If the combination of Socket type and protocol type results in an invalid Socket, this constructor throws a SocketException.
Note |
|---|
If this constructor throws a SocketException, use the SocketException::ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error. |
Note |
|---|
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework. |
Available since 10
.NET Framework
Available since 4.5
