boost::asio学习之[八]acceptor 点滴

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
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值