std::size_t do_parse_successor(const_buffer buf, ip::tcp::endpoint& ep) { const successor_frame<Addr>* frame = buffer_cast<const successor_frame<Addr>*>(buf); typename Addr::bytes_type ip_bytes; std::memcpy(ip_bytes.data(), frame->sucessor_ip, ip_bytes.size()); ep.address(Addr(ip_bytes)); ep.port(u16(frame->sucessor_port)); return sizeof(successor_frame<Addr>); }
connection::ptr_t connection::connect(boost::shared_ptr<local_node> node, ip::tcp::endpoint peer, routing_type rtype) { DLOG(INFO) << "Connecting: " << node->public_endpoint().port() << ", " << peer.address() << ':' << peer.port(); ptr_t con(new connection(node, rtype)); con->starting_connection(); con->incoming_port_ = peer.port(); con->link_.socket.lowest_layer().async_connect(peer, boost::bind(&connection::ssl_handshake, con, boost::asio::ssl::stream_base::client, placeholders::error)); return con; }
bool UpdateManager::isAddressInList(ip::tcp::endpoint &endpoint, std::list<boost::asio::ip::address> addresses) { ip::address address = endpoint.address(); std::list<ip::address>::iterator i = addresses.begin(); std::list<ip::address>::iterator end = addresses.end(); for ( ; i != end ; i++) { if ((*i) == address) return true; } return false; }
void session::start_connecting_to_peer(const ip::tcp::endpoint& peer) { TRACE() << peer; try { responder.open(peer.protocol()); responder.bind(parent_proxy.get_outgoing_endpoint()); } catch (const boost::system::system_error& e) { TRACE_ERROR(e.code()); return finish(e.code()); } responder.async_connect(peer, boost::bind(&session::finished_connecting_to_peer, this, placeholders::error())); }
void user_asyn_tcp_client::did_disconnect(const ip::tcp::endpoint &ep) { log_warn("end-point: %s:%d", ep.address().to_string().c_str(), ep.port()); }
void user_asyn_tcp_client::did_connect_to_host(const ip::tcp::endpoint &ep) { log_debug("end-point: %s:%d", ep.address().to_string().c_str(), ep.port()); // 登录 // do_login(); }