#include <cabal_tcpsocket.h>
Inheritance diagram for Cabal::TCPSocket:
Public Member Functions | |
TCPSocket (const long timeout=-1, const Address *local=0, const Address *remote=0) throw ( InitError ) | |
TCPSocket (const Address *local, const Address *remote=0) throw ( InitError ) | |
TCPSocket (const long timeout, const char *local_ip, const int port) throw ( InitError ) | |
virtual bool | close () |
Closes the socket. | |
bool | connect () |
Conencects with a remote host. | |
bool | connect (const Address &remote) |
Connect with a remote address. | |
bool | connect (const char *ip_addr, const int port) |
Connects to a remote host. | |
int | recvAll (void *buffer, const int len) |
Blocks until all the data is read. | |
int | sendAll (const void *buffer, const int len) |
Blocks until all the data is sent. | |
std::string | recvLine (const int maxCount=0) |
Blocks until a string terminated by CRLF is read. | |
int | sendLine (const std::string &val) |
int | send (const std::string &val) |
int | sendLine (const char *data) |
int | sendString (const char *data) |
bool | continueOp () |
Continue a previously timed out operation. | |
Protected Member Functions | |
virtual int | rawRecv (void *data, const int len) |
Subclasses hook to receive data. | |
virtual int | rawSend (const void *data, const int len) |
Subclasses hook to send data. | |
Protected Attributes | |
OpType | m_opType |
const void * | m_buffer |
int | m_buflen |
int | m_bufdone |
This class encapsulates a TCPSocket; most notably, it is capable to connect with a remote server, and it is returned by Cabal::ServerSocket::accept() on client incoming.
Definition at line 27 of file cabal_tcpsocket.h.
|
Closes the socket. The other end of the connection is notified of the will of this side to stop transmissions. Then, the superclass method is called.
Reimplemented from Cabal::Socket. Definition at line 79 of file cabal_tcpsocket.h. |
|
Connects to a remote host. This is an inline that builds an address and passes it to connect().
Definition at line 114 of file cabal_tcpsocket.h. References connect(), and Cabal::Address::set(). |
|
Connect with a remote address. If the socket times out in the meanwhile, the connection can be continued with continueOp() until a connection is eshtablished or an error is returned.
Definition at line 102 of file cabal_tcpsocket.h. References connect(). |
|
Conencects with a remote host. The host must be set in the "remote" field of this socket prior to call this method, or the program will be aborted. If the socket times out in the meanwhile, the connection can be continued with continueOp() until a connection is eshtablished or an error is returned.
Definition at line 18 of file ltlib/cabal_tcpsocket.cpp. References Cabal::Address::address(). Referenced by connect(). |
|
Continue a previously timed out operation. Returns false on error. Reimplemented from Cabal::Socket. Definition at line 170 of file ltlib/cabal_tcpsocket.cpp. |
|
Subclasses hook to receive data. This is called by recv() method to allow subclasses to specialize the job. All the preparation and error handling part are done by recv(), subclasses just need to implement this abstract method.
Implements Cabal::Socket. Definition at line 37 of file cabal_tcpsocket.h. |
|
Subclasses hook to send data. This is called by send() method to allow subclasses to specialize the job. All the preparation and error handling part are done by send(), subclasses just need to implement this abstract method.
Implements Cabal::Socket. Definition at line 42 of file cabal_tcpsocket.h. Referenced by sendAll(). |
|
Blocks until all the data is read. This function fills a given buffer with len bytes read from the socket. The function may return filling less than the requested amount of data if the socket times out; in this case, the return value is set to the amount of data read before the timeout has expired. If all the data is read, then the returned value will equal the len parameter.
Definition at line 150 of file ltlib/cabal_tcpsocket.cpp. References Cabal::Socket::hasTimedOut(), and Cabal::Socket::recv(). |
|
Blocks until all the data is sent. This function will repeatedly send the data (when the network layer allows it) until all the data is finally sent, or until the timeout expires. In this case, the return value is set to the amount of data sent before the timeout has expired. If all the data is sent, then the returned value will equal the len parameter.
Definition at line 130 of file ltlib/cabal_tcpsocket.cpp. References Cabal::Socket::hasTimedOut(), and rawSend(). |