32 #ifndef ASYNC_TCP_CONNECTION_INCLUDED 33 #define ASYNC_TCP_CONNECTION_INCLUDED 42 #include <sigc++/sigc++.h> 163 uint16_t remote_port,
197 virtual int write(
const void *buf,
int count);
227 bool isIdle(
void)
const {
return sock == -1; }
329 uint16_t remote_port;
337 void recvHandler(
FdWatch *watch);
338 void writeHandler(
FdWatch *watch);
bool isConnected(void) const
Check if the connection is established or not.
A system error occured (check errno)
The specified host was not found in the DNS.
A class for handling exiting TCP connections.
void setRecvBufLen(size_t recv_buf_len)
Set a new receive buffer size.
virtual ~TcpConnection(void)
Destructor.
A base class for creating a TCP client connection.
sigc::signal< void, TcpConnection *, DisconnectReason > disconnected
A signal that is emitted when a connection has been terminated.
void setRemotePort(uint16_t remote_port)
Setup information about the connection.
bool isIdle(void) const
Check if the connection is idle.
virtual void disconnect(void)
Disconnect from the remote host.
static const char * disconnectReasonStr(DisconnectReason reason)
Translate disconnect reason to a string.
static const int DEFAULT_RECV_BUF_LEN
The default length of the reception buffer.
void setSocket(int sock)
Setup information about the connection.
virtual void onDisconnected(DisconnectReason reason)
Called when a connection has been terminated.
virtual int write(const void *buf, int count)
Write data to the TCP connection.
virtual int onDataReceived(void *buf, int count)
Called when data has been received on the connection.
const IpAddress & remoteHost(void) const
Return the IP-address of the remote host.
A class for watching file descriptors.
void setRemoteAddr(const IpAddress &remote_addr)
Setup information about the connection.
TcpConnection(size_t recv_buf_len=DEFAULT_RECV_BUF_LEN)
Constructor.
uint16_t remotePort(void) const
Return the remote port used.
sigc::signal< void, bool > sendBufferFull
A signal that is emitted when the send buffer status changes.
Receiver buffer overflow.
DisconnectReason
Reason code for disconnects.
Disconnect ordered locally.
int socket(void) const
Return the socket file descriptor.
Namespace for the asynchronous programming classes.
Platform independent representation of an IP address.
A class for representing an IP address in an OS independent way.
sigc::signal< int, TcpConnection *, void *, int > dataReceived
A signal that is emitted when data has been received on the connection.
The remote host disconnected.