qb
2.0.0.0
C++17 Actor Framework
|
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"
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. |
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.
http://www.apache.org/licenses/LICENSE-2.0
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.
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.
Socket_ | The socket class type to use for the connection |
Func_ | The callback function type that will be called on connection completion |
remote | URI of the remote endpoint to connect to |
func | Callback function to call when connection completes |
timeout | Connection timeout in seconds (0 = no timeout) |
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.
Socket_ | The socket class type to use for the connection |
Func_ | The callback function type that will be called on connection completion |
existing_socket | An rvalue reference to an existing socket to be used for the connection |
remote | URI of the remote endpoint to connect to |
func | Callback function to call when connection completes |
timeout | Connection timeout in seconds (0 = no timeout) |