Socket Constructor (SocketType, ProtocolType)
Collapse the table of content
Expand the table of content

Socket Constructor (SocketType, ProtocolType)

.NET Framework (current version)
 

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
)

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.

System_CAPS_noteNote

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.

System_CAPS_noteNote

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.5
Return to top
Show:
© 2016 Microsoft