32 #ifndef ASYNC_TCP_CONNECTION_INCLUDED
33 #define ASYNC_TCP_CONNECTION_INCLUDED
42 #include <sigc++/sigc++.h>
152 explicit TcpConnection(
size_t recv_buf_len = DEFAULT_RECV_BUF_LEN);
162 uint16_t remote_port,
163 size_t recv_buf_len = DEFAULT_RECV_BUF_LEN);
196 int write(
const void *buf,
int count);
226 bool isIdle(
void)
const {
return sock == -1; }
296 uint16_t remote_port;
304 void recvHandler(
FdWatch *watch);
305 void writeHandler(
FdWatch *watch);
A system error occured (check errno)
int socket(void) const
Return the socket file descriptor.
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.
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 isConnected(void) const
Check if the connection is established or not.
uint16_t remotePort(void) const
Return the remote port used.
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.
int write(const void *buf, int count)
Write data to the TCP connection.
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.
const IpAddress & remoteHost(void) const
Return the IP-address of the remote host.
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.
~TcpConnection(void)
Destructor.
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.
bool isIdle(void) const
Check if the connection is idle.
The remote host disconnected.