UCommon
|
A generic tcp socket class that offers i/o buffering. More...
#include <buffer.h>
Public Member Functions | |
void | close (void) |
Close active connection. | |
void | open (const TCPServer *server, size_t size=536) |
Connect a tcp socket to a client from a listener. | |
void | open (const char *host, const char *service, size_t size=536) |
Connect a tcp client session to a specific host uri. | |
TCPBuffer () | |
Construct an unconnected tcp client and specify our service profile. | |
TCPBuffer (const TCPServer *server, size_t size=536) | |
Construct a tcp server session from a listening socket. | |
TCPBuffer (const char *host, const char *service, size_t size=536) | |
Construct a tcp client session connected to a specific host uri. | |
virtual | ~TCPBuffer () |
Destroy the tcp socket and release all resources. | |
Protected Member Functions | |
bool | _blocking (void) |
Return true if blocking. | |
void | _buffer (size_t size) |
void | _clear (void) |
Method to clear low level i/o error. | |
int | _err (void) const |
Method to get low level i/o error. | |
virtual bool | _pending (void) |
Check for pending tcp or ssl data. | |
virtual size_t | _pull (char *address, size_t size) |
Method to pull buffer from physical i/o (read). | |
virtual size_t | _push (const char *address, size_t size) |
Method to push buffer into physical i/o (write). | |
socket_t | getsocket (void) const |
Get the low level socket object. |
A generic tcp socket class that offers i/o buffering.
All user i/o operations are directly inherited from the IOBuffer base class public members. Some additional members are added for layering ssl services.
ucommon::TCPBuffer::TCPBuffer | ( | const TCPServer * | server, |
size_t | size = 536 |
||
) |
Construct a tcp server session from a listening socket.
server | socket we are created from. |
size | of buffer and tcp fragments. |
ucommon::TCPBuffer::TCPBuffer | ( | const char * | host, |
const char * | service, | ||
size_t | size = 536 |
||
) |
Construct a tcp client session connected to a specific host uri.
host | and optional :port we are connecting to. |
service | identifier of our client. |
size | of buffer and tcp fragments. |
int ucommon::TCPBuffer::_err | ( | void | ) | const [protected, virtual] |
Method to get low level i/o error.
Implements ucommon::BufferProtocol.
virtual bool ucommon::TCPBuffer::_pending | ( | void | ) | [protected, virtual] |
Check for pending tcp or ssl data.
Reimplemented from ucommon::BufferProtocol.
Reimplemented in ucommon::SSLBuffer.
virtual size_t ucommon::TCPBuffer::_pull | ( | char * | address, |
size_t | size | ||
) | [protected, virtual] |
Method to pull buffer from physical i/o (read).
The address is passed to this virtual since it is hidden as private.
address | of buffer to pull data into. |
size | of buffer area being pulled.. |
Implements ucommon::BufferProtocol.
Reimplemented in ucommon::SSLBuffer.
virtual size_t ucommon::TCPBuffer::_push | ( | const char * | address, |
size_t | size | ||
) | [protected, virtual] |
Method to push buffer into physical i/o (write).
The address is passed to this virtual since it is hidden as private.
address | of data to push. |
size | of data to push. |
Implements ucommon::BufferProtocol.
Reimplemented in ucommon::SSLBuffer.
socket_t ucommon::TCPBuffer::getsocket | ( | void | ) | const [inline, protected] |
void ucommon::TCPBuffer::open | ( | const TCPServer * | server, |
size_t | size = 536 |
||
) |
Connect a tcp socket to a client from a listener.
If the socket was already connected, it is automatically closed first.
server | we are connected from. |
size | of buffer and tcp fragments. |
void ucommon::TCPBuffer::open | ( | const char * | host, |
const char * | service, | ||
size_t | size = 536 |
||
) |
Connect a tcp client session to a specific host uri.
If the socket was already connected, it is automatically closed first.
host | we are connecting. |
service | to connect to. |
size | of buffer and tcp fragments. |
Reimplemented in ucommon::SSLBuffer.