UCommon
|
Secure socket buffer. More...
#include <secure.h>
Public Member Functions | |
bool | _flush (void) |
Flush buffer to physical i/o. | |
bool | _pending (void) |
Check for pending tcp or ssl data. | |
size_t | _pull (char *address, size_t size) |
Method to pull buffer from physical i/o (read). | |
size_t | _push (char *address, size_t size) |
void | close (void) |
Close active connection. | |
bool | is_secure (void) |
void | open (char *host, char *service, size_t size=536) |
Connect a ssl client session to a specific host uri. | |
void | release (void) |
Release (free) buffer memory. | |
SSLBuffer (secure::client_t context) | |
SSLBuffer (TCPServer *server, secure::server_t context, size_t size=536) | |
![]() | |
void | open (TCPServer *server, size_t size=536) |
Connect a tcp socket to a client from a listener. | |
TCPBuffer () | |
Construct an unconnected tcp client and specify our service profile. | |
TCPBuffer (TCPServer *server, size_t size=536) | |
Construct a tcp server session from a listening socket. | |
TCPBuffer (char *host, 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. | |
![]() | |
int | _getch (void) |
Get a character from the buffer. | |
int | _putch (int ch) |
Put a character into the buffer. | |
bool | eof (void) |
Check if at end of input. | |
int | err (void) |
bool | flush (void) |
Flush buffered memory to physical I/O. | |
size_t | get (char *address, size_t count) |
Get memory from the buffer. | |
size_t | getline (char *string, size_t size) |
Get text as a line of input from the buffer. | |
size_t | getline (string &buffer) |
Get a string as a line of input from the buffer. | |
bool | is_input (void) |
See if input active. | |
bool | is_open (void) |
See if buffer open. | |
bool | is_output (void) |
See if output active. | |
bool | is_pending (void) |
See if pending input. | |
operator bool () | |
See if buffer open. | |
bool | operator! () |
See if buffer closed. | |
size_t | printf (const char *format,...) |
Print formatted string to the buffer. | |
void | purge (void) |
Purge any pending input or output buffer data. | |
size_t | put (const char *address, size_t count=0) |
Put memory into the buffer. | |
size_t | putline (const char *string) |
Put a string as a line of output to the buffer. | |
void | reset (void) |
Reset input buffer state. | |
void | seteof (void) |
Set eof flag. | |
![]() | |
int | get (void) |
Get the next character. | |
int | put (int code) |
Put the next character. |
Protected Attributes | |
secure::bufio_t | bio |
bool | server |
secure::session_t | ssl |
bool | verify |
Additional Inherited Members | |
![]() | |
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) |
socket_t | getsocket (void) |
Get the low level socket object. | |
![]() | |
virtual int | _err (void) const =0 |
Method to get low level i/o error. | |
virtual size_t | _push (const char *address, size_t size)=0 |
Method to push buffer into physical i/o (write). | |
void | allocate (size_t size, type_t access=BUF_RDWR) |
Allocate I/O buffer(s) of specified size. | |
BufferProtocol () | |
Construct an empty (unallocated) buffer. | |
BufferProtocol (size_t size, type_t access=BUF_RDWR) | |
Construct a buffer of pre-allocated size and access type. | |
char * | gather (size_t size) |
Gather returns a pointer to contiguous input of specified size. | |
char * | request (size_t size) |
Request workspace in output buffer. | |
void | seteol (const char *string) |
Set end of line marker. | |
size_t | unread (void) |
Get current input position. | |
size_t | unsaved (void) |
Get current output position. | |
virtual | ~BufferProtocol () |
Destroy object by releasing buffer memory. | |
![]() | |
int | blocking (bool enable) |
Set socket blocking I/O mode. | |
int | broadcast (bool enable) |
Set socket for unicast mode broadcasts. | |
void | cancel (void) |
Cancel pending i/o by shutting down the socket. | |
int | connectto (struct addrinfo *list) |
Connect our socket to a remote host from an address list. | |
int | disconnect (void) |
Disconnect a connected socket. | |
int | drop (struct addrinfo *list) |
Drop socket from multicast group. | |
int | err (void) |
Get error code. | |
int | getError (void) |
Get socket error code. | |
unsigned | getPending (void) |
Get the number of bytes of data in the socket receive buffer. | |
int | gettype (void) |
Get the type of a socket. | |
bool | isConnected (void) |
Test if socket is connected. | |
bool | isPending (unsigned value) |
See the number of bytes in the receive queue. | |
int | join (struct addrinfo *list) |
Join socket to multicast group. | |
int | keepalive (bool enable) |
Set socket for keepalive packets. | |
int | loopback (bool enable) |
Set loopback to read multicast packets we broadcast. | |
int | multicast (unsigned ttl=1) |
Set multicast mode and multicast broadcast range. | |
int | nodelay (void) |
Set nodelay option for tcp socket. | |
operator bool () | |
Test if socket is valid. | |
operator socket_t () | |
Get the socket descriptor by casting. | |
bool | operator! () |
Test if socket is invalid. | |
socket_t | operator* () |
Get the socket descriptor by pointer reference. | |
Socket & | operator= (socket_t socket) |
Assign socket from a socket descriptor. | |
size_t | peek (void *data, size_t number) |
Peek at data waiting in the socket receive buffer. | |
size_t | printf (char *format,...) |
Print formatted string to socket. | |
int | priority (int scheduling) |
Set packet priority, 0 to 6 unless privileged. | |
size_t | readfrom (void *data, size_t number, struct sockaddr_storage *address=((void *) 0)) |
Read data from the socket receive buffer. | |
size_t | readline (char *data, size_t size) |
Read a newline of text data from the socket and save in NULL terminated string. | |
size_t | readline (string &buffer) |
Read a string of input from the socket and strip trailing newline. | |
int | recvsize (unsigned size) |
Set the size of the socket receive buffer. | |
unsigned | segsize (unsigned size) |
Set segment size and get mtu of a socket. | |
int | sendsize (unsigned size) |
Set the size of the socket send buffer. | |
int | sendwait (unsigned size) |
Set the size to wait before sending. | |
bool | setccid (uint8_t ccid) |
Set ccid of dccp socket. | |
void | shutdown (void) |
Shutdown the socket communication channel. | |
Socket () | |
Create a socket object for use. | |
Socket (Socket &existing) | |
Create socket as duped handle of existing socket. | |
Socket (socket_t socket) | |
Create socket from existing socket descriptor. | |
Socket (struct addrinfo *address) | |
Create and connect a socket to an address from an address list. | |
Socket (int family, int type, int protocol=0) | |
Create an unbound socket of a specific type. | |
Socket (char *address, char *port, int family=0, int type=0, int protocol=0) | |
Create a bound socket. | |
int | tos (int type) |
Set the type of service field of outgoing packets. | |
int | ttl (unsigned char time) |
Set the time to live before packets expire. | |
int | wait (timeout_t timeout=Timer::inf) |
Socket i/o timer setting. | |
bool | waitPending (timeout_t timeout=0) |
Test for pending input data. | |
bool | waitSending (timeout_t timeout=0) |
Test for output data sent. | |
size_t | writes (char *string) |
Write a null terminated string to the socket. | |
size_t | writeto (void *data, size_t number, struct sockaddr *address=((void *) 0)) |
Write data to the socket send buffer. | |
virtual | ~Socket () |
Shutdown, close, and destroy socket. |
Secure socket buffer.
This is used to create ssl socket connections for both clients and servers. The use depends in part on the type of context created and passed at construction time. If no context is passed (NULL), then this reverts to TCPBuffer behavior.
|
virtual |
Check for pending tcp or ssl data.
Reimplemented from ucommon::TCPBuffer.
|
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 ucommon::TCPBuffer.
void ucommon::SSLBuffer::open | ( | char * | host, |
char * | service, | ||
size_t | size = 536 |
||
) |
Connect a ssl client session to a specific host uri.
If the socket was already connected, it is automatically closed first.
host | we are connecting to. |
service | to connect to. |
size | of buffer and tcp fragments. |
Reimplemented from ucommon::TCPBuffer.