Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Socket Constructor (SocketType, ProtocolType)

Socket Constructor (SocketType, ProtocolType)

.NET Framework 4.6 and 4.5

Initializes a new instance of the Socket class using the specified socket type and protocol.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

public Socket(
	SocketType socketType,
	ProtocolType protocolType


Type: System.Net.Sockets.SocketType

One of the SocketType values.

Type: System.Net.Sockets.ProtocolType

One of the ProtocolType values.


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.


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.


This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

.NET Framework

Supported in: 4.6, 4.5
© 2015 Microsoft