#include <tcp_client.hpp>
tacopie::tcp_server is the class providing TCP Client features. The tcp_client works entirely asynchronously
◆ async_read_callback_t
callback to be called on async read completion takes the read_result as a parameter
◆ async_write_callback_t
callback to be called on async write completion takes the write_result as a parameter
◆ disconnection_handler_t
disconnection handle called whenever a disconnection occured
◆ tcp_client()
tacopie::tcp_client::tcp_client |
( |
tcp_socket && |
socket | ) |
|
|
explicit |
custom ctor build socket from existing socket
- Parameters
-
socket | tcp_socket instance to be used for building the client (socket will be moved) |
◆ async_read()
void tacopie::tcp_client::async_read |
( |
const read_request & |
request | ) |
|
async read operation
- Parameters
-
request | read request information |
◆ async_write()
void tacopie::tcp_client::async_write |
( |
const write_request & |
request | ) |
|
async write operation
- Parameters
-
request | write request information |
◆ connect()
void tacopie::tcp_client::connect |
( |
const std::string & |
host, |
|
|
std::uint32_t |
port, |
|
|
std::uint32_t |
timeout_msecs = 0 |
|
) |
| |
Connect the socket to the remote server.
- Parameters
-
host | Hostname of the target server |
port | Port of the target server |
timeout_msecs | maximum time to connect (will block until connect succeed or timeout expire). 0 will block undefinitely. If timeout expires, connection fails |
◆ disconnect()
void tacopie::tcp_client::disconnect |
( |
bool |
wait_for_removal = false | ) |
|
Disconnect the tcp_client if it was currently connected.
- Parameters
-
wait_for_removal | When sets to true, disconnect blocks until the underlying TCP client has been effectively removed from the io_service and that all the underlying callbacks have completed. |
◆ get_host()
const std::string& tacopie::tcp_client::get_host |
( |
void |
| ) |
const |
- Returns
- the hostname associated with the underlying socket.
◆ get_io_service()
- Returns
- io service monitoring this tcp connection
◆ get_port()
std::uint32_t tacopie::tcp_client::get_port |
( |
void |
| ) |
const |
- Returns
- the port associated with the underlying socket.
◆ get_socket() [1/2]
◆ get_socket() [2/2]
◆ is_connected()
bool tacopie::tcp_client::is_connected |
( |
void |
| ) |
const |
- Returns
- whether the client is currently connected or not
◆ operator!=()
bool tacopie::tcp_client::operator!= |
( |
const tcp_client & |
rhs | ) |
const |
comparison operator
- Returns
- true when the underlying sockets are different (different file descriptor or socket type).
◆ operator==()
bool tacopie::tcp_client::operator== |
( |
const tcp_client & |
rhs | ) |
const |
comparison operator
- Returns
- true when the underlying sockets are the same (same file descriptor and socket type).
◆ set_on_disconnection_handler()
set on disconnection handler
- Parameters
-
disconnection_handler | the handler to be called on disconnection |
The documentation for this class was generated from the following file: