Networking TS

PrevUpHomeNext

socket_base::reuse_address

Socket option to allow the socket to be bound to an address that is already in use.

typedef implementation_defined reuse_address;

Implements the SOL_SOCKET/SO_REUSEADDR socket option.

Examples

Setting the option:

std::experimental::net::ip::tcp::acceptor acceptor(io_context);
...
std::experimental::net::socket_base::reuse_address option(true);
acceptor.set_option(option);

Getting the current option value:

std::experimental::net::ip::tcp::acceptor acceptor(io_context);
...
std::experimental::net::socket_base::reuse_address option;
acceptor.get_option(option);
bool is_set = option.value();

PrevUpHomeNext