Connect the socket to the specified endpoint. * This function is used to connect a socket to the specified remote endpoint. * The function call will block until the connection is successfully made or * an error occurs. * * The socket is automatically opened if it is not already open. If the * connect fails, and the socket was automatically opened, the socket is * not returned to
| 848 | * @endcode |
| 849 | */ |
| 850 | void connect(const endpoint_type& peer_endpoint) |
| 851 | { |
| 852 | boost::system::error_code ec; |
| 853 | if (!is_open()) |
| 854 | { |
| 855 | impl_.get_service().open(impl_.get_implementation(), |
| 856 | peer_endpoint.protocol(), ec); |
| 857 | boost::asio::detail::throw_error(ec, "connect"); |
| 858 | } |
| 859 | impl_.get_service().connect(impl_.get_implementation(), peer_endpoint, ec); |
| 860 | boost::asio::detail::throw_error(ec, "connect"); |
| 861 | } |
| 862 | |
| 863 | /// Connect the socket to the specified endpoint. |
| 864 | /** |