static inline void pack(msgpack::packer<Stream>& target, const endpoint_type& source) { const std::string address = source.address().to_string(); const unsigned short port = source.port(); type_traits<tuple_type>::pack(target, tuple_type(address, port)); }
/// Bind the fiber acceptor to the specified local endpoint. boost::system::error_code bind(implementation_type& impl, const endpoint_type& endpoint, boost::system::error_code& ec) { impl->p_fib_demux = &(endpoint.demux()); impl->p_fib_demux->bind(endpoint.port(), impl, ec); return ec; }
boost::system::error_code bind ( endpoint_type const& e ) { // Only fixed port is handled right now. if ( e.port() != FIXED_PORT ) return make_error_code( boost::system::errc::invalid_argument ); // Generate our local address. if ( e.address().is_v4() ) local_endpoint( generate_unique_ipv4_endpoint( e.port() ) ); else local_endpoint( generate_unique_ipv6_endpoint( e.port() ) ); add_route_to_socket( local_endpoint(), this ); return boost::system::error_code(); }
static inline void unpack(const msgpack::object& source, endpoint_type& target) { std::string address; unsigned short port; type_traits<tuple_type>::unpack(source, std::move(std::tie(address, port))); target.address(boost::asio::ip::address::from_string(address)); target.port(port); }
virtual request_t build_request(endpoint_type ep, error_code & ec) { request_t rc = request_t(); if(!ep.address().is_v4()) { ec = error_code(boost::asio::error::address_family_not_supported); return rc; } rc.detail.version = 4; rc.detail.command = 1; rc.detail.destination_port = ::htons(ep.port()); rc.detail.destination_address = ep.address().to_v4().to_bytes(); rc.detail.end_marker = 0; return rc; }
std::uint16_t port() const { return endpoint_.port(); }