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

◆ poll()

bool xtd::net::sockets::socket::poll ( int32  micro_seconds,
xtd::net::sockets::select_mode  mode 
)

Determines the status of the xtd::net::sockets::socket.

Parameters
micro_secondsThe time to wait for a response, in microseconds.
modeOne of the xtd::net::sockets::select_mode values.
Returns
The status of the xtd::net::sockets::socket based on the polling mode value passed in the mode parameter.
Mode Return Value
xtd::net::sockets::select_mode::select_read true if xtd::net::sockets::socket::listen has been called and a connection is pending;
-or-
true if data is available for reading;
-or-
true if the connection has been closed, reset, or terminated; otherwise, returns false.
xtd::net::sockets::select_mode::select_write true, if processing a xtd::net::sockets::socket::connect, and the connection has succeeded;
-or-
true if data can be sent; otherwise, returns false.
xtd::net::sockets::select_mode::select_error true if processing a xtd::net::sockets::socket::connect that does not block, and the connection has failed;
-or-
true if xtd::net::sockets::socket_option_name::out_of_band_inline is not set and out-of-band data is available; otherwise, returns false.
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
The xtd::net::sockets::socket::poll method checks the state of the xtd::net::sockets::socket. Specify xtd::net::sockets::select_mode::select_read for the select_mode parameter to determine if the xtd::net::sockets::socket is readable. Specify xtd::net::sockets::select_mode::select_write to determine if the xtd::net::sockets::socket is writable. Use SelectMode.SelectError to detect an error condition. Poll will block execution until the specified time period, measured in microseconds, elapses. Set the microSeconds parameter to a negative integer if you would like to wait indefinitely for a response. If you want to check the status of multiple sockets, you might prefer to use the xtd::net::sockets::socket::select method.
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.