Boost.Socks Logo

PrevUpHomeNext
async_connect (1 of 2 overloads)

Asynchronously connect to the application server through a SOCKS5 server.

Synopsis

Defined in header <boost/socks/connect.hpp>

template<
    class AsyncStream,
    class CompletionToken>
DEDUCED
async_connect(
    AsyncStream& s,
    endpoint const& ep,
    auth_options const& opt,
    CompletionToken&& token);
Description

This function establishes a connection to the application server through a SOCKS5 server. This composed operation includes the greeting, sub-negotiation, and connect steps of the SOCKS5 protocol. After this operation, the client can communicate with SOCKS5 proxy as if the talking to the application server.

Preconditions

The AsyncStream should be connected to a SOCKS5 server. The endpoint might contain IPv4 or IPv6 address.

Example
boost::asio::connect(s, resolver.resolve(socks_host, socks_service));
socks_io::async_connect(
    s, app_host_endpoint, "username", ec,
    [](error_code ec, endpoint ep)
{
    if (!ec.failed())
    {
        // write to the application host
        do_write();
    }
});
Parameters

Name

Description

s

SyncStream connected to a SOCKS server.

ep

Application server endpoint.

opt

Authentication options

token

Asio CompletionToken.

References

Convenience header <boost/socks.hpp>


PrevUpHomeNext