/// Set an option on the socket. /** * This function is used to set an option on the socket. * * @param option The new option value to be set on the socket. * * @throws boost::system::system_error Thrown on failure. * * @sa SettableSocketOption @n * boost::asio::socket_base::broadcast @n * boost::asio::socket_base::do_not_route @n * boost::asio::socket_base::keep_alive @n * boost::asio::socket_base::linger @n * boost::asio::socket_base::receive_buffer_size @n * boost::asio::socket_base::receive_low_watermark @n * boost::asio::socket_base::reuse_address @n * boost::asio::socket_base::send_buffer_size @n * boost::asio::socket_base::send_low_watermark @n * boost::asio::ip::multicast::join_group @n * boost::asio::ip::multicast::leave_group @n * boost::asio::ip::multicast::enable_loopback @n * boost::asio::ip::multicast::outbound_interface @n * boost::asio::ip::multicast::hops @n * boost::asio::ip::tcp::no_delay * * @par Example * Setting the IPPROTO_TCP/TCP_NODELAY option: * @code * boost::asio::ip::tcp::socket socket(io_service); * ... * boost::asio::ip::tcp::no_delay option(true); * socket.set_option(option); * @endcode */ template <typename SettableSocketOption> void set_option(const SettableSocketOption& option) { boost::system::error_code ec; this->get_service().set_option(this->get_implementation(), option, ec); boost::asio::detail::throw_error(ec, "set_option"); }
时间: 2024-10-06 14:33:50