Async 1.8.0
|
A base class for creating a TCP client connection. More...
#include <AsyncTcpClientBase.h>
Public Member Functions | |
TcpClientBase (TcpConnection *con) | |
Constructor. | |
TcpClientBase (TcpConnection *con, const std::string &remote_host, uint16_t remote_port) | |
Constructor. | |
TcpClientBase (TcpConnection *con, const IpAddress &remote_ip, uint16_t remote_port) | |
Constructor. | |
virtual | ~TcpClientBase (void) |
Destructor. | |
virtual TcpClientBase & | operator= (TcpClientBase &&other) |
Move assignmnt operator. | |
std::string | remoteHostName (void) const |
Get the name of the remote host as given to connect() | |
void | setBindIp (const IpAddress &bind_ip) |
Bind to the interface having the specified IP address. | |
const IpAddress & | bindIp (void) const |
Get the bind IP address. | |
void | connect (const std::string &remote_host, uint16_t remote_port) |
Connect to the remote host. | |
void | connect (const Async::IpAddress &remote_ip, uint16_t remote_port) |
Connect to the remote host. | |
void | connect (void) |
Connect to the remote host. | |
virtual void | disconnect (void)=0 |
Disconnect from the remote host. | |
bool | isIdle (void) const |
Check if the connection is idle. | |
TcpConnection * | conObj (void) |
Return the connection object for this client connection. | |
Public Attributes | |
sigc::signal< void > | connected |
A signal that is emitted when a connection has been established. | |
Protected Member Functions | |
virtual void | closeConnection (void) |
Check if the connection has been fully connected. | |
virtual void | connectionEstablished (void) |
Called when the connection has been established to the server. | |
virtual void | emitConnected (void) |
A base class for creating a TCP client connection.
This is a base class for creating TCP client connections. It should notmally not be used direclt but rather the TcpClient class should be used.
Definition at line 121 of file AsyncTcpClientBase.h.
|
explicit |
Constructor.
con | The connection object associated with this client |
The object will be constructed and variables will be initialized but no connection will be created until the connect function (see TcpClient::connect) is called. When using this variant of the constructor the connect method which take host and port must be used.
Async::TcpClientBase::TcpClientBase | ( | TcpConnection * | con, |
const std::string & | remote_host, | ||
uint16_t | remote_port ) |
Constructor.
con | The connection object associated with this client |
remote_host | The hostname of the remote host |
remote_port | The port on the remote host to connect to |
The object will be constructed and variables will be initialized but no connection will be created until the connect function (see TcpClient::connect) is called.
Async::TcpClientBase::TcpClientBase | ( | TcpConnection * | con, |
const IpAddress & | remote_ip, | ||
uint16_t | remote_port ) |
Constructor.
con | The connection object associated with this client |
remote_ip | The IP address of the remote host |
remote_port | The port on the remote host to connect to |
The object will be constructed and variables will be initialized but no connection will be created until the connect function (see TcpClient::connect) is called.
|
virtual |
Destructor.
|
inline |
Get the bind IP address.
Definition at line 201 of file AsyncTcpClientBase.h.
|
protectedvirtual |
Check if the connection has been fully connected.
This function return true when the connection has been fully established. It will continue to return true even after disconnection and will be reset at the moment when a new connection attempt is made.
Disconnect from the remote peer
This function is used internally to close the connection to the remote peer.
Reimplemented in Async::TcpClient< ConT >, and Async::TcpPrioClient< ConT >.
Referenced by Async::TcpClient< ConT >::closeConnection(), and Async::TcpPrioClient< ConT >::closeConnection().
void Async::TcpClientBase::connect | ( | const Async::IpAddress & | remote_ip, |
uint16_t | remote_port ) |
Connect to the remote host.
remote_ip | The IP address of the remote host |
remote_port | The port on the remote host to connect to |
This function will initiate a connection to the remote host. The connection must not be written to before the connected signal (see TcpClient::connected) has been emitted. If the connection is already established or pending, an assertion will be raised.
void Async::TcpClientBase::connect | ( | const std::string & | remote_host, |
uint16_t | remote_port ) |
Connect to the remote host.
remote_host | The hostname of the remote host |
remote_port | The port on the remote host to connect to |
This function will initiate a connection to the remote host. The connection must not be written to before the connected signal (see TcpClient::connected) has been emitted. If the connection is already established or pending, an assertion will be raised.
void Async::TcpClientBase::connect | ( | void | ) |
Connect to the remote host.
This function will initiate a connection to the remote host. The connection must not be written to before the connected signal (see TcpClient::connected) has been emitted. If the connection is already established or pending, an assertion will be raised.
|
inlineprotectedvirtual |
Called when the connection has been established to the server.
This function may be overridden by inheriting classes to get informed of when a connection has been established. The overriding function should normally call this function.
Reimplemented in Async::TcpPrioClientBase.
Definition at line 294 of file AsyncTcpClientBase.h.
References emitConnected().
|
inline |
Return the connection object for this client connection.
Definition at line 258 of file AsyncTcpClientBase.h.
|
pure virtual |
Disconnect from the remote host.
Call this function to disconnect from the remote host. If already disconnected, nothing will be done. The disconnected signal is not emitted when this function is called
Implemented in Async::TcpClient< ConT >, Async::TcpPrioClient< ConT >, and Async::TcpPrioClientBase.
|
inlineprotectedvirtual |
Definition at line 300 of file AsyncTcpClientBase.h.
References connected.
Referenced by connectionEstablished().
|
inline |
Check if the connection is idle.
A connection being idle means that it is not connected nor connecting.
Definition at line 252 of file AsyncTcpClientBase.h.
References Async::DnsLookup::isPending().
Referenced by Async::TcpClient< ConT >::isIdle().
|
virtual |
Move assignmnt operator.
other | The object to move from |
Reimplemented in Async::TcpClient< ConT >, and Async::TcpPrioClientBase.
|
inline |
Get the name of the remote host as given to connect()
This function return the name of the remote host as it was given to the connect call. If an IP address was used the text representation of that will be returned.
Definition at line 182 of file AsyncTcpClientBase.h.
References Async::DnsLookup::label(), Async::TcpConnection::remoteHost(), and Async::IpAddress::toString().
void Async::TcpClientBase::setBindIp | ( | const IpAddress & | bind_ip | ) |
Bind to the interface having the specified IP address.
bind_ip | The IP address of the interface to bind to |
sigc::signal<void> Async::TcpClientBase::connected |
A signal that is emitted when a connection has been established.
Definition at line 263 of file AsyncTcpClientBase.h.
Referenced by emitConnected().