|
|
TCP streams are used to represent TCP client connections to a server by TCP protocol servers for accepting client connections. The TCP stream is a C++ "stream" class, and can accept streaming of data to and from other C++ objects using the << and >> operators.
TCPStream () |
The constructor required for "tcpstream", a more C++ style version of the TCPStream class.
void Allocate (int size) |
Used to allocate the buffer space needed for iostream operations. This function is called by the constructor.
Parameters:
size | of stream buffers from constructor. |
void endStream (void) |
Used to terminate the buffer space and cleanup the socket connection. This fucntion is called by the destructor.
int underflow (void) |
This streambuf method is used to load the input buffer through the established tcp socket connection.
Returns: char from get buffer, EOF if not connected.
int overflow (int ch) |
This streambuf method is used to write the output buffer through the established tcp connection.
Parameters:
char | to push through. |
Returns: char pushed through.
iostream * tcp (void) |
Used in derived classes to refer to the current object via it's iostream. For example, to send a set of characters in a derived method, one might use *tcp() << "test".
Returns: stream pointer of this object.
TCPStream (TCPSocket &server, int size = 512) |
Create a TCP stream by accepting a connection from a bound TCP socket acting as a server. This performs an "accept" call.
Parameters:
size | of streaming input and output buffers. |
TCPStream (const InetHostAddress &host, tpport_t port, int size = 512) |
Create a TCP stream by connecting to a TCP socket (on a remote machine).
Parameters:
host | address of remote TCP server. |
port | number to connect. |
size | of streaming input and output buffers. |
TCPStream (const TCPStream &source) |
A copy constructor creates a new stream buffer.
Parameters:
source | of copy. |
~TCPStream () |
Flush and empty all buffers, and then remove the allocated buffers.
int sync (void) |
Flushes the stream input and output buffers, writes pending output.
Returns: 0 on success.
bool isPending (sockpend_t pend, timeout_t timeout = TIMEOUT_INF) |
Get the status of pending stream data. This can be used to examine if input or output is waiting, or if an error or disconnect has occured on the stream. If a read buffer contains data then input is ready and if write buffer contains data it is first flushed and then checked.
Reimplemented from Socket
int getBufferSize (void) |
Return the size of the current stream buffering used.
Returns: size of stream buffers.