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

◆ linger_time() [1/2]

uint32 xtd::net::sockets::linger_option::linger_time ( ) const
noexcept

Gets the amount of time to remain connected after calling the xtd::net::sockets::socket::close method if data remains to be sent.

Returns
The amount of time, in seconds, to remain connected after calling xtd::net::sockets::socket::close.
Remarks
Use this value if you want to determine how long a closed xtd::net::sockets::socket will attempt to transfer unsent data before timing out. You can also set this value to the desired time-out period, in seconds.
If the xtd::net::sockets::linger_option::enabled property is true, and you set xtd::net::sockets::linger_option::linger_time to 0, the xtd::net::sockets::socket discards any pending data to send in the outgoing network buffer. If you change this value, you must pass the altered xtd::net::sockets::linger_option instance to the xtd::net::sockets::socket::set_socket_option method or set the xtd::net::sockets::socket::linger_state or xtd::net::sockets::tcp_client::linger_state property.
The following table describes the behavior on the xtd::net::sockets::socket::close and xtd::net::sockets::tcp_client::close methods based on the possible values of the enable and seconds parameters when an xtd::net::sockets::linger_option instance is created and set in the xtd::net::sockets::socket::linger_state or xtd::net::sockets::socket xtd::net::sockets::tcp_client::linger_state property.
enable seconds Behavior
false (disabled), the default value The time-out is not applicable, (default). Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.
true (enabled) A nonzero time-out Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.
true (enabled) A zero timeout. Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.
The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the xtd::net::sockets::socket::linger_state property is not set.
When the xtd::net::sockets::linger_option::linger_time property stored in the xtd::net::sockets::socket::linger_state property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and virtual.