acceptor
acceptor(io_service);
acceptot(io_service, protocol_type);
acceptor(io_service, endpoint_type, reuse_address = true);
acceptor(io_service, protocol_type, native_handle_type);
acceptor(basic_socket_acceptor &&other);
types
1.0 broadcast
Socket option to permit sending of broadcast messages.
example
udp::socket socket(io_service);
socket_base::broadcast option(ture);
socket.set_option(option);
...
boost::asio::socket_base::broadcast option;
socket.get_option(option);
bool is_set = option.value();
1.1 bytes_readable
IO control command to get the amount of data that can be read without blocking.
example
tcp::socket_base::bytes_readable command(true);
socket.io_control(command);
std::size_t bytes_readable = command.get();
1.2 debug
Socket option to enable socket-level debugging.
example
Setting the option:
tcp::socket socket(io_service);
...
boost::asio::socket_base::debug option(true);
socket.set_option(option);
Getting the current option value:
tcp::socket socket(io_service);
...
boost::asio::socket_base::debug option;
socket.get_option(option);
bool is_set = option.value();
1.3 do_not_route
Socket option to prevent routing, use local interfaces only.
example
Setting the option:
tcp::socket socket(io_service);
...
boost::asio::socket_base::do_not_route option(true);
socket.set_option(option);
Getting the current option value:
tcp::socket socket(io_service);
...
boost::asio::socket_base::do_not_route option;
socket.get_option(option);
bool is_set = option.value();
1.4 enable_connection_aborted
Socket option to report aborted connections on accept.
Implements a custom socket option that determines whether or not
an accept operation is permitted to fail with boost::asio::error::connection_aborted.
By default the option is false.
example
Setting the option:
tcp::acceptor acceptor(io_service);
...
boost::asio::socket_base::enable_connection_a
boost::asio学习之[八]acceptor 点滴
最新推荐文章于 2024-04-30 10:54:20 发布
本文详细介绍了Boost.Asio库中的acceptor对象,包括构造方法、各种socket选项如广播、非阻塞模式、套接字复用等的设置和获取方法,以及acceptor的成员函数如accept、bind、listen等操作。
摘要由CSDN通过智能技术生成