A generic tcp socket class that offers i/o buffering. More...
#include <buffer.h>
Public Member Functions | |
void | blocking (timeout_t timeout=Timer::inf) |
Set timeout interval and blocking. | |
void | close (void) |
Close active connection. | |
void | open (char *host, size_t size=536) |
Connect a tcp client session to a specific host uri. | |
void | open (TCPServer *server, size_t size=536) |
Connect a tcp socket to a client from a listener. | |
bool | pending (void) |
Check for pending tcp or ssl data. | |
TCPSocket (char *service, char *host, size_t size=536) | |
Construct a tcp client session connected to a specific host uri. | |
TCPSocket (TCPServer *server, size_t size=536) | |
Construct a tcp server session from a listening socket. | |
TCPSocket (char *service) | |
Construct an unconnected tcp client and specify our service profile. | |
virtual | ~TCPSocket () |
Destroy the tcp socket and release all resources. | |
Protected Member Functions | |
virtual size_t | _pull (char *address, size_t size) |
Method to pull buffer from physical i/o (read). | |
virtual size_t | _push (char *address, size_t size) |
Method to push buffer into physical i/o (write). | |
short | getservice (void) |
Get the effective "service" port identifier of the socket. | |
socket_t | getsocket (void) |
Get the low level socket object. | |
size_t | peek (char *data, size_t size, timeout_t timeout=Timer::inf) |
Peek at socket input. | |
char * | tag (void) |
Get the tag used for this socket. |
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.
Definition at line 493 of file buffer.h.
ucc::TCPSocket::TCPSocket | ( | char * | service | ) |
Construct an unconnected tcp client and specify our service profile.
service | identifer, usually by name. |
ucc::TCPSocket::TCPSocket | ( | 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. |
ucc::TCPSocket::TCPSocket | ( | char * | service, | |
char * | host, | |||
size_t | size = 536 | |||
) |
Construct a tcp client session connected to a specific host uri.
service | identifier of our client. | |
host | and optional :port we are connecting to. | |
size | of buffer and tcp fragments. |
virtual size_t ucc::TCPSocket::_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.. |
Reimplemented from ucc::IOBuffer.
Reimplemented in ucc::SSocket.
virtual size_t ucc::TCPSocket::_push | ( | 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. |
Reimplemented from ucc::IOBuffer.
Reimplemented in ucc::SSocket.
void ucc::TCPSocket::blocking | ( | timeout_t | timeout = Timer::inf |
) |
Set timeout interval and blocking.
timeout | to use. |
short ucc::TCPSocket::getservice | ( | void | ) | [inline, protected] |
Get the effective "service" port identifier of the socket.
If the socket was created from a listener, this will be the port number of the listening socket, and hence can be useful to determine which service connected and whether ssl is needed. If this is a client socket, it will be the service port of the peer socket.
socket_t ucc::TCPSocket::getsocket | ( | void | ) | [inline, protected] |
void ucc::TCPSocket::open | ( | char * | host, | |
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 | and optional :port we are connecting to. | |
size | of buffer and tcp fragments. |
Reimplemented in ucc::SSocket.
void ucc::TCPSocket::open | ( | 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. |
Reimplemented in ucc::SSocket.
size_t ucc::TCPSocket::peek | ( | char * | data, | |
size_t | size, | |||
timeout_t | timeout = Timer::inf | |||
) | [protected] |
Peek at socket input.
This might be used to get a header at connection and to see if ssl/tls service is needed.
data | buffer to store peek results. | |
size | of data to peek. | |
timeout | to wait for peek. |
bool ucc::TCPSocket::pending | ( | void | ) | [virtual] |
Check for pending tcp or ssl data.
Reimplemented from ucc::IOBuffer.
Reimplemented in ucc::SSocket.
char* ucc::TCPSocket::tag | ( | void | ) | [inline, protected] |