This class contain only methods related to data transfert (send, receive). Use a derived class to be able to open a connection, like FileCx or TcpCx. You can send/receive arbitrary data or file, or you can use the Packet class that already contains useful attributes. More...
#include <Cx.hh>
Inheritance diagram for Cx:

Public Member Functions | |
| bool | poll (int timeout=0) |
| Check if there is some data to fetch. | |
| void | begin () |
| Begin a send-in-batch-mode packet. | |
| void | commit () |
| End a send-in-batch-mode packet. It flush the write buffer. | |
| void | send (const Packet &pkt) |
| Send a packet, or add it to the write buffer if in batch mode. | |
| Packet * | receive () |
| Receive a Packet class. | |
Protected Member Functions | |
| virtual bool | pollInternal (int *timeout)=0 |
| virtual int | recvData (bool use_exception)=0 |
| virtual void | sendData (unsigned char *data, unsigned size)=0 |
| virtual void | print (std::ostream &os) const |
| Print some debug info. | |
Protected Attributes | |
| int | fd_ |
| The file descriptor. | |
| int | state_ |
| CX_WRITE / CX_READ. | |
| char | last_error_ [64] |
| Last cx error, if not using exception. | |
| unsigned char | buff_send_ [BUF_SEND_SIZE] |
| Internal buffer for outcoming packets. | |
| bool | batch_send_ |
| True if we must pack messages before sending. | |
| unsigned | buff_send_tail_ |
| Index to the end of used buff_send_. | |
| unsigned char | buff_recv_ [BUF_RECV_SIZE] |
| Internal buffer for incoming packets. | |
| unsigned | buff_recv_head_ |
| unsigned | buff_recv_tail_ |
Friends | |
| class | CxPool |
| std::ostream & | operator<< (std::ostream &os, const Cx &cx) |
| Print some debug info into the stream. | |
This class contain only methods related to data transfert (send, receive). Use a derived class to be able to open a connection, like FileCx or TcpCx. You can send/receive arbitrary data or file, or you can use the Packet class that already contains useful attributes.
Take care that all read/write functions throw exception on error, instead of using a return value indicator. Be sure to add the necessary try/catch blocks.
| bool Cx::poll | ( | int | timeout = 0 |
) |
Check if there is some data to fetch.
| NetError | Thrown on network error, such as timeout or broken pipe. |
| Packet * Cx::receive | ( | ) |
| void Cx::send | ( | const Packet & | pkt | ) |
1.4.7