irccd  3.0.3
Public Types | Public Member Functions | List of all members
irccd::ip_connector Class Reference

TCP/IP connector. More...

#include <connector.hpp>

Inheritance diagram for irccd::ip_connector:
irccd::basic_socket_connector irccd::connector

Public Types

using socket_type = boost::asio::ip::tcp::socket
 
- Public Types inherited from irccd::connector
using handler = std::function< void(std::error_code, std::shared_ptr< stream >)>
 Connect completion handler. More...
 

Public Member Functions

 ip_connector (boost::asio::io_context &service, std::string hostname, std::string port, bool ipv4=true, bool ipv6=true) noexcept
 
template<typename Socket , typename Handler >
void connect (Socket &sc, Handler handler)
 
void connect (handler handler)
 
- Public Member Functions inherited from irccd::basic_socket_connector
 basic_socket_connector (boost::asio::io_context &service)
 
auto get_service () const noexcept -> const boost::asio::io_context &
 
auto get_service () noexcept -> boost::asio::io_context &
 
- Public Member Functions inherited from irccd::connector
 connector ()=default
 
virtual ~connector ()=default
 

Additional Inherited Members

- Protected Attributes inherited from irccd::basic_socket_connector
boost::asio::io_context & service_
 The I/O service. More...
 

Detailed Description

TCP/IP connector.

Member Typedef Documentation

◆ socket_type

using irccd::ip_connector::socket_type = boost::asio::ip::tcp::socket

Underlying socket type.

Constructor & Destructor Documentation

◆ ip_connector()

irccd::ip_connector::ip_connector ( boost::asio::io_context &  service,
std::string  hostname,
std::string  port,
bool  ipv4 = true,
bool  ipv6 = true 
)
inlinenoexcept

Construct the TCP/IP connector.

Precondition
at least ipv4 or ipv6 must be true
Parameters
servicethe I/O context
hostnamethe hostname
portthe port or service name
ipv4enable IPv4
ipv6enable IPv6

Member Function Documentation

◆ connect() [1/2]

void irccd::ip_connector::connect ( handler  handler)
inlinevirtual

Start asynchronous connect.

Once the client is connected, the original acceptor must be kept until it is destroyed.

Precondition
another connect operation must not be running
handler != nullptr
Parameters
handlerthe handler

Implements irccd::connector.

◆ connect() [2/2]

template<typename Socket , typename Handler >
void irccd::ip_connector::connect ( Socket &  sc,
Handler  handler 
)
inline

Connect to the given socket.

Parameters
scthe socket type
handlerthe handler
Note
implemented for SocketConnector concept

The documentation for this class was generated from the following file: