Streamable tcp connection between client and server. More...
#include <stream.h>
Inherits std::streambuf, and std::iostream.
Public Member Functions | |
void | close (void) |
Close an active stream connection. | |
void | open (Socket::address &address, unsigned segment=536) |
Open a stream connection to a tcp service. | |
operator bool () const | |
See if stream connection is active. | |
bool | operator! () const |
See if stream is disconnected. | |
int | sync (void) |
Flush the stream input and output buffers, writes pending output. | |
tcpstream (const tcpstream ©) | |
Copy constructor... | |
tcpstream (ListenSocket &listener, unsigned segsize=536, timeout_t timeout=0) | |
Create a stream from an existing tcp listener. | |
tcpstream (Socket::address &address, unsigned segsize=536, timeout_t timeout=0) | |
A convenience constructor that creates a connected tcp stream directly from an address. | |
tcpstream (int family=PF_INET, timeout_t timeout=0) | |
Create an unconnected tcp stream object that is idle until opened. | |
virtual | ~tcpstream () |
Destroy a tcp stream. | |
Protected Member Functions | |
int | overflow (int ch) |
This streambuf method is used to write the output buffer through the established tcp connection. | |
void | release (void) |
Release the tcp stream and destroy the underlying socket. | |
int | uflow () |
This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode. | |
int | underflow () |
This streambuf method is used to load the input buffer through the established tcp socket connection. | |
Protected Attributes | |
size_t | bufsize |
char * | gbuf |
char * | pbuf |
socket_t | so |
timeout_t | timeout |
Streamable tcp connection between client and server.
The tcp stream class can represent a client connection to a server or an instance of a service generated by a tcp listener. As a stream class, data can be manipulated using the << and >> operators.
Definition at line 52 of file stream.h.
ucc::tcpstream::tcpstream | ( | const tcpstream & | copy | ) |
Copy constructor...
copy | for object. |
ucc::tcpstream::tcpstream | ( | ListenSocket & | listener, | |
unsigned | segsize = 536 , |
|||
timeout_t | timeout = 0 | |||
) |
Create a stream from an existing tcp listener.
listener | to accept connection from. | |
segsize | for tcp segments and buffering. | |
timeout | for socket i/o operations. |
ucc::tcpstream::tcpstream | ( | int | family = PF_INET , |
|
timeout_t | timeout = 0 | |||
) |
Create an unconnected tcp stream object that is idle until opened.
family | of protocol to create. | |
timeout | for socket i/o operations. |
ucc::tcpstream::tcpstream | ( | Socket::address & | address, | |
unsigned | segsize = 536 , |
|||
timeout_t | timeout = 0 | |||
) |
A convenience constructor that creates a connected tcp stream directly from an address.
The socket is constructed to match the type of the the address family in the socket address that is passed.
address | of service to connect to. | |
segsize | for tcp segments and buffering. | |
timeout | for socket i/o operations. |
void ucc::tcpstream::close | ( | void | ) |
Close an active stream connection.
This does not release the socket but is a disconnect.
void ucc::tcpstream::open | ( | Socket::address & | address, | |
unsigned | segment = 536 | |||
) |
Open a stream connection to a tcp service.
address | of service to access. | |
segment | buffering size to use. |
ucc::tcpstream::operator bool | ( | ) | const [inline] |
bool ucc::tcpstream::operator! | ( | ) | const [inline] |
int ucc::tcpstream::overflow | ( | int | ch | ) | [protected] |
This streambuf method is used to write the output buffer through the established tcp connection.
ch | char to push through. |
int ucc::tcpstream::sync | ( | void | ) |
Flush the stream input and output buffers, writes pending output.
int ucc::tcpstream::uflow | ( | ) | [protected] |
This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode.
Also this method will handle proper use of buffers if not in interative mode.
int ucc::tcpstream::underflow | ( | ) | [protected] |
This streambuf method is used to load the input buffer through the established tcp socket connection.