qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches

Asynchronous TCP connection establishment utilities. More...

#include <qb/io.h>
#include <qb/io/system/sys__socket.h>
#include "../../uri.h"
#include "../event/io.h"
#include "../listener.h"
Include dependency graph for connector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  qb::io::async::tcp::connector< Socket_, Func_ >
 Handles asynchronous TCP connection establishment. More...

Functions

template<typename Socket_, typename Func_>
void qb::io::async::tcp::connect (uri const &remote, Func_ &&func, double timeout=0.)
 Initiates an asynchronous TCP connection.
template<typename Socket_, typename Func_>
void qb::io::async::tcp::connect (Socket_ &&existing_socket, uri const &remote, Func_ &&func, double timeout=0.)
 Initiates an asynchronous TCP connection using an existing socket.

Detailed Description

Asynchronous TCP connection establishment utilities.

This file provides utilities for establishing asynchronous TCP connections. It defines the connector class template which handles the async connection process and a connect function for initiating asynchronous connections.

Author
qb - C++ Actor Framework

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ connect() [1/2]

template<typename Socket_, typename Func_>
void qb::io::async::tcp::connect ( uri const & remote,
Func_ && func,
double timeout = 0. )

Initiates an asynchronous TCP connection.

This function creates a new connector object to establish an asynchronous TCP connection to the specified remote endpoint. When the connection completes or fails, the provided callback function is called with the socket. The connector object manages its own lifetime.

Template Parameters
Socket_The socket class type to use for the connection
Func_The callback function type that will be called on connection completion
Parameters
remoteURI of the remote endpoint to connect to
funcCallback function to call when connection completes
timeoutConnection timeout in seconds (0 = no timeout)

◆ connect() [2/2]

template<typename Socket_, typename Func_>
void qb::io::async::tcp::connect ( Socket_ && existing_socket,
uri const & remote,
Func_ && func,
double timeout = 0. )

Initiates an asynchronous TCP connection using an existing socket.

This function creates a new connector object to establish an asynchronous TCP connection to the specified remote endpoint, using an existing socket instance. The provided socket is moved. When the connection completes or fails, the provided callback function is called with the socket. The connector object manages its own lifetime.

Template Parameters
Socket_The socket class type to use for the connection
Func_The callback function type that will be called on connection completion
Parameters
existing_socketAn rvalue reference to an existing socket to be used for the connection
remoteURI of the remote endpoint to connect to
funcCallback function to call when connection completes
timeoutConnection timeout in seconds (0 = no timeout)