| Home | Libraries | People | FAQ | More

###### basic_stream::connect (3 of 10 overloads)

Establishes a connection by trying each endpoint in a sequence.

###### Synopsis

    template<
        class EndpointSequence>
    Protocol::endpoint
    connect(
        EndpointSequence const& endpoints);

###### Description

This function attempts to connect the stream to one of a sequence of endpoints by trying each endpoint until a connection is successfully established. The underlying socket is automatically opened if needed. An automatically opened socket is not returned to the closed state upon failure.

The algorithm, known as a composed operation, is implemented in terms of calls to the underlying socket's `connect` function.

###### Parameters

Name | Description
--- | ---
`endpoints` | A sequence of endpoints.

###### Return Value

The successfully connected endpoint.

###### Exceptions

Type | Thrown On
--- | ---
`[link beast.ref.boost__beast__system_error system_error]` | Thrown on failure. If the sequence is empty, the associated error code is `net::error::not_found`. Otherwise, contains the error from the last connection attempt.