示例#1
0
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>);
}
示例#2
0
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;
}
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();
}