Google

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

TCPStream Class Reference

#include <socket.h>

Inheritance diagram for TCPStream:

Socket streambuf iostream TCPSession tcpstream URLStream List of all members.

Public Methods

 TCPStream (TCPSocket &server, int size = 512)
 Create a TCP stream by accepting a connection from a bound TCP socket acting as a server. More...

 TCPStream (const InetHostAddress &host, tpport_t port, int size = 512)
 Create a TCP stream by connecting to a TCP socket (on a remote machine). More...

 TCPStream (const TCPStream &source)
 A copy constructor creates a new stream buffer. More...

 ~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. More...

bool isPending (sockpend_t pend, timeout_t timeout = TIMEOUT_INF)
 Get the status of pending stream data. More...

int getBufferSize (void) const
 Return the size of the current stream buffering used. More...


Protected Methods

 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. More...

void endStream (void)
 Used to terminate the buffer space and cleanup the socket connection. More...

virtual int underflow (void)
 This streambuf method is used to load the input buffer through the established tcp socket connection. More...

int uflow (void)
 This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode. More...

int overflow (int ch)
 This streambuf method is used to write the output buffer through the established tcp connection. More...

void Connect (const InetHostAddress &host, tpport_t port, int size)
 Create a TCP stream by connecting to a TCP socket (on a remote machine). More...

iostreamtcp (void)
 Used in derived classes to refer to the current object via it's iostream. More...


Protected Attributes

int bufsize
char* gbuf
char * pbuf

Friends

TCPStream& crlf (TCPStream&)
TCPStream& lfcr (TCPStream&)

Constructor & Destructor Documentation

TCPStream::TCPStream ( ) [protected]
 

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

TCPStream::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::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::TCPStream ( const TCPStream & source )
 

A copy constructor creates a new stream buffer.

Parameters:
source   of copy.

TCPStream::~TCPStream ( ) [inline]
 

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


Member Function Documentation

void TCPStream::Allocate ( int size ) [protected]
 

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 TCPStream::Connect ( const InetHostAddress & host,
tpport_t port,
int size ) [protected]
 

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.

void TCPStream::endStream ( void ) [protected]
 

Used to terminate the buffer space and cleanup the socket connection.

This fucntion is called by the destructor.

int TCPStream::getBufferSize ( void ) const [inline]
 

Return the size of the current stream buffering used.

Returns:
size of stream buffers.

bool TCPStream::isPending ( sockpend_t pend,
timeout_t timeout = TIMEOUT_INF ) [virtual]
 

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 TCPStream::overflow ( int ch ) [protected]
 

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

Parameters:
char   to push through.
Returns:
char pushed through.

int TCPStream::sync ( void )
 

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

Returns:
0 on success.

iostream * TCPStream::tcp ( void ) [inline, 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.

int TCPStream::uflow ( void ) [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.

Returns:
char from tcp socket connection, EOF if not connected.

int TCPStream::underflow ( void ) [protected, virtual]
 

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.

Reimplemented in URLStream.


Friends And Related Function Documentation

TCPStream& crlf ( TCPStream & ) [friend]
 

TCPStream& lfcr ( TCPStream & ) [friend]
 


Member Data Documentation

int TCPStream::bufsize [protected]
 

char * TCPStream::gbuf [protected]
 

char * TCPStream::pbuf [protected]
 


The documentation for this class was generated from the following file:
Generated at Fri Mar 23 10:47:56 2001 for CommonC++ by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000