Export (0) Print
Expand All

Socket Constructor (SocketType, ProtocolType)

.NET Framework 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)

new : 
        socketType:SocketType * 
        protocolType:ProtocolType -> Socket

Parameters

socketType
Type: System.Net.Sockets.SocketType

One of the SocketType values.

protocolType
Type: System.Net.Sockets.ProtocolType

One of the ProtocolType values.

ExceptionCondition
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.

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.

NoteNote

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.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft