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

◆ listen() [1/2]

void xtd::net::sockets::socket::listen ( size_t  backlog)

Places a xtd::net::sockets::socket in a listening state.

Parameters
backlogThe maximum length of the pending connections queue.
Exceptions
xtd::net::sockets::socket_exceptionAn error occurred when attempting to access the socket.
xtd::object_closed_exceptionThe xtd::net::sockets::socket has been closed.
Remarks
xtd::net::sockets::socket::listen causes a connection-oriented xtd::net::sockets::socket to listen for incoming connection attempts. The backlog parameter specifies the number of incoming connections that can be queued for acceptance. To determine the maximum number of connections you can specify, retrieve the xtd::net::sockets::socket_option_name::max_connections value. xtd::net::sockets::socket::listen does not block.
Note
If you receive a xtd::net::sockets::socket_exception, use the xtd::net::sockets::socket_exception 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.
You must call the xtd::net::sockets::socket::bind method before calling xtd::net::sockets::socket::listen, or xtd::net::sockets::socket::listen will throw a xtd::net::sockets::socket_exception.
The backlog parameter is limited to different values depending on the Operating System. You may specify a higher value, but the backlog will be limited based on the Operating System.