xtd 0.2.0
Loading...
Searching...
No Matches

◆ socket() [4/5]

xtd::net::sockets::socket::socket ( xtd::net::sockets::socket_type  socket_type,
xtd::net::sockets::protocol_type  protocol_type 
)

Initializes a new instance of the xtd::net::sockets::socket class using the specified socket type and protocol. If the operating system supports IPv6, this constructor creates a dual-mode socket; otherwise, it creates an IPv4 socket.

Parameters
socket_typeOne of the xtd::net::sockets::socket_type values.
protocol_typeOne of the xtd::net::sockets::protocol_type values.
Exceptions
xtd::net:sockets::socket_exceptionThe combination of socket_type and protocol_type results in an invalid socket.
Remarks
The socket_type parameter specifies the type of the xtd::net::sockets::socket class and the protocol_type parameter specifies the protocol used by xtd::net::sockets::socket. The two parameters are not independent. Often the xtd::net::sockets::socket type is implicit in the protocol. If the combination of xtd::net::sockets::socket type and protocol type results in an invalid xtd::net::sockets::socket, this constructor throws a xtd::net::sockets::socket_exception.
Note
If this constructor throws a xtd::net::sockets::socket_exception, use the xtd::net::sockets::socket_exception::error_code property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.