class TCPStream

streamable TCP socket connection. More...

Definition#include <socket.h>
InheritsSocket, streambuf, iostream
Inherited bytcpstream, TCPSession
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Members


Detailed Description

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 ()
[protected]

The constructor required for "tcpstream", a more C++ style version of the TCPStream class.

void Allocate (int size)
[protected]

Used to allocate the buffer space needed for iostream operations. This function is called by the constructor.

Parameters:
sizeof stream buffers from constructor.

void endStream (void)
[protected]

Used to terminate the buffer space and cleanup the socket connection. This fucntion is called by the destructor.

int underflow (void)
[protected]

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)
[protected]

This streambuf method is used to write the output buffer through the established tcp connection.

Parameters:
charto push through.

Returns: char pushed through.

int sync (void)
[protected]

Flushes the stream input and output buffers, writes pending output.

Returns: 0 on success.

iostream * tcp (void)
[protected]

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:
sizeof streaming input and output buffers.

TCPStream (InetHostAddress &host, short port, int size = 512)

Create a TCP stream by connecting to a TCP socket (on a remote machine).

Parameters:
hostaddress of remote TCP server.
portnumber to connect.
sizeof streaming input and output buffers.

TCPStream (const TCPStream &source)

A copy constructor creates a new stream buffer.

Parameters:
sourceof copy.

~TCPStream ()

Flush and empty all buffers, and then remove the allocated buffers.

int getBufferSize (void)

Return the size of the current stream buffering used.

Returns: size of stream buffers.