This class implements TCP/IP data connections. Nagle algorithm is turned off, to speed up little but frequent transfers. More...
#include <TcpCx.hh>
Inheritance diagram for TcpCx:

Public Member Functions | |
| void | connect (const char *host, int port) |
| Open a TCP connection to an host, to a specified port. | |
| void | listen (int port) |
| Prepare to accepts connection. | |
| TcpCx * | accept () |
| Accept any connection from the outside. | |
Protected Member Functions | |
| virtual bool | pollInternal (int *timeout) |
| virtual int | recvData (bool use_exception) |
| virtual void | sendData (unsigned char *data, unsigned size) |
| virtual void | print (std::ostream &os) const |
| Print some debug info. | |
This class implements TCP/IP data connections. Nagle algorithm is turned off, to speed up little but frequent transfers.
TcpCx* cx = new TcpCx; Packet* p; cx->connect("localhost", 4242); if (!cx->poll(5)) { delete cx;// connection failed return; } cx->send(Packet(CX_INIT, 1)); if (!cx->poll(5)) { delete cx; // can't receive anything return; } p = cx->receive(); delete cx; // close connection
| TcpCx * TcpCx::accept | ( | ) |
| void TcpCx::connect | ( | const char * | host, | |
| int | port | |||
| ) |
Open a TCP connection to an host, to a specified port.
For client.
| host | Host to connect to. Could be an IP adresse or an host name resolvable by the operating system. |
| port | Port to connect to (1-65535). |
| NetError | Thrown on OS error. |
| void TcpCx::listen | ( | int | port | ) |
Prepare to accepts connection.
For server.
| port | Will accept connection on this port. |
| NetError | Thrown on OS error. |
1.4.7