Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

basic_socket::linger

Inherited from socket_base.

Socket option to specify whether the socket lingers on close if unsent data is present.

typedef implementation_defined linger;

Implements the SOL_SOCKET/SO_LINGER socket option.

Examples

Setting the option:

boost::asio::ip::tcp::socket socket(io_context);
...
boost::asio::socket_base::linger option(true, 30);
socket.set_option(option);

Getting the current option value:

boost::asio::ip::tcp::socket socket(io_context);
...
boost::asio::socket_base::linger option;
socket.get_option(option);
bool is_set = option.enabled();
unsigned short timeout = option.timeout();
Requirements

Header: boost/asio/basic_socket.hpp

Convenience header: boost/asio.hpp


PrevUpHomeNext