Esempio n. 1
0
void protocol::start_connect(const code& ec, const config::authority& peer)
{
    if (ec)
    {
        handle_connect(ec, nullptr, peer);
        return;
    }

    if (is_connected(peer))
    {
        handle_connect(error::address_in_use, nullptr, peer);
        return;
    }

    if (is_blacklisted(peer))
    {
        handle_connect(error::address_blocked, nullptr, peer);
        return;
    }

    log_debug(LOG_PROTOCOL)
        << "Connecting to peer [" << peer.to_string() << "]";

    // OUTBOUND CONNECT (sequential)
    network_.connect(peer.to_hostname(), peer.port(),
        dispatch_.ordered_delegate(&protocol::handle_connect,
            this, _1, _2, peer));
}
Esempio n. 2
0
void connector::connect(const config::authority& authority,
    connect_handler handler)
{
    connect(authority.to_hostname(), authority.port(), handler);
}