10#include <FMEThirdPartyWarningsDisable.h>
11#include <boost/asio/ip/tcp.hpp>
13#include <boost/asio.hpp>
14#include <boost/asio/ip/basic_resolver.hpp>
15#include <boost/asio/ip/tcp.hpp>
16#include <boost/asio/query.hpp>
18#include <FMEThirdPartyWarningsRestore.h>
51 template<
typename ConnectCompletionHandler>
52 void async_connect(
const std::string& host,
const unsigned short port, ConnectCompletionHandler&& handler)
54 using TcpResolver = boost::asio::ip::tcp::resolver;
55 typedef boost::asio::ip::tcp::resolver::results_type ResolverResultsType;
57 auto resolver = std::make_shared<TcpResolver>( socket.get_executor() );
58 auto hostStr = (host ==
"localhost" ?
"127.0.0.1" : host);
59 resolver->async_resolve(hostStr, std::to_string(port),
60 [
this, handler, resolver](
const ErrorCode& ec_resolve,
const ResolverResultsType& iterator ) {
62 socket.async_connect(*iterator.begin(), handler);
#define ASYNCHRONOUSIO_EXPORT
Abstract base class for an asynchronous channel supporting read and write of binary data.
std::function< void(const ErrorCode &, const std::size_t)> CompletionHandler
A TCP acceptor listening on a given port and interface address.
A TCP socket class implementing the asio::Socket interface.
std::shared_ptr< Context > context
void async_write(const void *buffer, const std::size_t buffer_size, const CompletionHandler &handler) override
void async_connect(const std::string &host, const unsigned short port, ConnectCompletionHandler &&handler)
TcpSocket(const TcpSocket &)=delete
void async_read(void *buffer, const std::size_t buffer_size, const CompletionHandler &handler) override
boost::asio::ip::tcp::socket socket
TcpSocket & operator=(const TcpSocket &)=delete
TcpSocket(std::shared_ptr< Context > context)
bool is_valid() const override
boost::system::error_code ErrorCode