void tcp_socket::bind(const fc::ip::endpoint& local_endpoint) { try { my->_sock.bind(boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4(local_endpoint.get_address()), local_endpoint.port())); } catch (const std::exception& except) { elog("Exception binding outgoing connection to desired local endpoint ${endpoint}: ${what}", ("endpoint", local_endpoint)("what", except.what())); FC_THROW("error binding to ${endpoint}: ${what}", ("endpoint", local_endpoint)("what", except.what())); } }
boost::asio::ip::udp::endpoint to_asio_ep( const fc::ip::endpoint& e ) { return boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4(e.get_address()), e.port() ); }
void tcp_socket::connect_to( const fc::ip::endpoint& e ) { fc::asio::tcp::connect(my->_sock, fc::asio::tcp::endpoint( boost::asio::ip::address_v4(e.get_address()), e.port() ) ); }
void tcp_server::listen( const fc::ip::endpoint& ep ) { if( !my ) my = new impl; try { my->_accept.bind(boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::from_string((string)ep.get_address()), ep.port())); my->_accept.listen(); } FC_RETHROW_EXCEPTIONS(warn, "error listening on socket"); }
void tcp_socket::connect_to( const fc::ip::endpoint& remote_endpoint ) { fc::asio::tcp::connect(my->_sock, fc::asio::tcp::endpoint( boost::asio::ip::address_v4(remote_endpoint.get_address()), remote_endpoint.port() ) ); }