SYNOPSIS

#include <socket.h>

Inherits streambuf, ost::Socket, and iostream.

Inherited by ost::SSLStream, ost::TCPSession, and ost::URLStream.

Public Member Functions

TCPStream (Family family=IPV4, bool throwflag=true, timeout_t to=0)

The constructor required for building other classes or to start an unconnected TCPStream for connect. void disconnect (void)

Disconnect the current session and prepare for a new one. int getSegmentSize (void)

Get protocol segment size. TCPStream (TCPSocket &server, bool throwflag=true, timeout_t timeout=0)

Create a TCP stream by accepting a connection from a bound TCP socket acting as a server. TCPStream (TCPV6Socket &server, bool throwflag=true, timeout_t timeout=0)

void connect (TCPSocket &server)

Accept a connection from a TCP Server. void connect (TCPV6Socket &server)

TCPStream (const IPV4Host &host, tpport_t port, unsigned mss=536, bool throwflag=true, timeout_t timeout=0)

Create a TCP stream by connecting to a TCP socket (on a remote machine). TCPStream (const IPV6Host &host, tpport_t port, unsigned mss=536, bool throwflag=true, timeout_t timeout=0)

TCPStream (const char *name, Family family=IPV4, unsigned mss=536, bool throwflag=false, timeout_t timer=0)

Construct a named TCP Socket connected to a remote machine. void setTimeout (timeout_t timer)

Set the I/O operation timeout for socket I/O operations. TCPStream (const TCPStream &source)

A copy constructor creates a new stream buffer. virtual ~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. size_t printf (const char *format,...)

Print content into a socket. bool isPending (Pending pend, timeout_t timeout=TIMEOUT_INF)

Get the status of pending stream data. ssize_t peek (void *buf, size_t len)

Examine contents of next waiting packet. size_t getBufferSize (void) const

Return the size of the current stream buffering used.

Protected Member Functions

void allocate (size_t size)

Used to allocate the buffer space needed for iostream operations. void endStream (void)

Used to terminate the buffer space and cleanup the socket connection. int underflow ()

This streambuf method is used to load the input buffer through the established tcp socket connection. int uflow ()

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

This streambuf method is used to write the output buffer through the established tcp connection. void connect (const IPV4Host &host, tpport_t port, unsigned mss=536)

Create a TCP stream by connecting to a TCP socket (on a remote machine). void connect (const IPV6Host &host, tpport_t port, unsigned mss=536)

void connect (const char *name, unsigned mss=536)

Connect a TCP stream to a named destination host and port number, using getaddrinfo interface if available. std::iostream * tcp (void)

Used in derived classes to refer to the current object via it's iostream.

Protected Attributes

timeout_t timeout

size_t bufsize

Family family

char * gbuf

char * pbuf

Friends

TCPStream & crlf (TCPStream &)

TCPStream & lfcr (TCPStream &)

Additional Inherited 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 itself can be formed either by connecting to a bound network address of a TCP server, or can be created when 'accepting' a network connection from a TCP server.

Author:

David Sugar [email protected] streamable TCP socket connection.

Examples: tcp.cpp, and tcpstr1.cpp.

Constructor & Destructor Documentation

ost::TCPStream::TCPStream (\fBFamily\fPfamily = \fC\fBIPV4\fP\fP, boolthrowflag = \fCtrue\fP, \fBtimeout_t\fPto = \fC0\fP)

The constructor required for building other classes or to start an unconnected TCPStream for connect.

ost::TCPStream::TCPStream (\fBTCPSocket\fP &server, boolthrowflag = \fCtrue\fP, \fBtimeout_t\fPtimeout = \fC0\fP)

Create a TCP stream by accepting a connection from a bound TCP socket acting as a server. This performs an 'accept' call.

Parameters:

server socket listening

throwflag flag to throw errors.

timeout for all operations.

ost::TCPStream::TCPStream (\fBTCPV6Socket\fP &server, boolthrowflag = \fCtrue\fP, \fBtimeout_t\fPtimeout = \fC0\fP)

ost::TCPStream::TCPStream (const \fBIPV4Host\fP &host, \fBtpport_t\fPport, unsignedmss = \fC536\fP, boolthrowflag = \fCtrue\fP, \fBtimeout_t\fPtimeout = \fC0\fP)

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.

mss maximum segment size of streaming buffers.

throwflag flag to throw errors.

timeout for all operations.

ost::TCPStream::TCPStream (const \fBIPV6Host\fP &host, \fBtpport_t\fPport, unsignedmss = \fC536\fP, boolthrowflag = \fCtrue\fP, \fBtimeout_t\fPtimeout = \fC0\fP)

ost::TCPStream::TCPStream (const char *name, \fBFamily\fPfamily = \fC\fBIPV4\fP\fP, unsignedmss = \fC536\fP, boolthrowflag = \fCfalse\fP, \fBtimeout_t\fPtimer = \fC0\fP)

Construct a named TCP Socket connected to a remote machine.

Parameters:

name of remote service.

family of protocol.

mss maximum segment size of streaming buffers.

throwflag flag to throw errors.

timer for timeout for all operations.

ost::TCPStream::TCPStream (const \fBTCPStream\fP &source)

A copy constructor creates a new stream buffer.

Parameters:

source reference of stream to copy from.

virtual ost::TCPStream::~TCPStream ()\fC [virtual]\fP

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

Member Function Documentation

void ost::TCPStream::allocate (size_tsize)\fC [protected]\fP

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 ost::TCPStream::connect (const \fBIPV4Host\fP &host, \fBtpport_t\fPport, unsignedmss = \fC536\fP)\fC [protected]\fP

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.

mss maximum segment size of streaming buffers.

Examples: tcp.cpp.

void ost::TCPStream::connect (const \fBIPV6Host\fP &host, \fBtpport_t\fPport, unsignedmss = \fC536\fP)\fC [protected]\fP

void ost::TCPStream::connect (const char *name, unsignedmss = \fC536\fP)\fC [protected]\fP

Connect a TCP stream to a named destination host and port number, using getaddrinfo interface if available.

Parameters:

name of host and service to connect

mss maximum segment size of stream buffer

void ost::TCPStream::connect (\fBTCPSocket\fP &server)

Accept a connection from a TCP Server.

Parameters:

server socket listening

void ost::TCPStream::connect (\fBTCPV6Socket\fP &server)

void ost::TCPStream::disconnect (void)

Disconnect the current session and prepare for a new one.

Examples: tcp.cpp, and tcpstr1.cpp.

void ost::TCPStream::endStream (void)\fC [protected]\fP

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

size_t ost::TCPStream::getBufferSize (void) const\fC [inline]\fP

Return the size of the current stream buffering used.

Returns:

size of stream buffers.

int ost::TCPStream::getSegmentSize (void)

Get protocol segment size.

Examples: tcp.cpp.

bool ost::TCPStream::isPending (\fBPending\fPpend, \fBtimeout_t\fPtimeout = \fC\fBTIMEOUT_INF\fP\fP)\fC [virtual]\fP

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 ost::Socket.

Examples: tcp.cpp.

int ost::TCPStream::overflow (intch)\fC [protected]\fP

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

Parameters:

ch char to push through.

Returns:

char pushed through.

ssize_t ost::TCPStream::peek (void *buf, size_tlen)\fC [inline]\fP

Examine contents of next waiting packet.

Parameters:

buf pointer to packet buffer for contents.

len of packet buffer.

Returns:

number of bytes examined.

References _IOLEN64.

size_t ost::TCPStream::printf (const char *format, ...)

Print content into a socket.

Returns:

count of bytes sent.

Parameters:

format string

void ost::TCPStream::setTimeout (\fBtimeout_t\fPtimer)\fC [inline]\fP

Set the I/O operation timeout for socket I/O operations.

Parameters:

timer to change timeout.

int ost::TCPStream::sync (void)

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

Returns:

0 on success.

std::iostream* ost::TCPStream::tcp (void)\fC [inline]\fP, \fC [protected]\fP

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 ost::TCPStream::uflow ()\fC [protected]\fP

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 ost::TCPStream::underflow ()\fC [protected]\fP

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.

Friends And Related Function Documentation

\fBTCPStream\fP& crlf (\fBTCPStream\fP &)\fC [friend]\fP

\fBTCPStream\fP& lfcr (\fBTCPStream\fP &)\fC [friend]\fP

Member Data Documentation

size_t ost::TCPStream::bufsize\fC [protected]\fP

\fBFamily\fP ost::TCPStream::family\fC [protected]\fP

char* ost::TCPStream::gbuf\fC [protected]\fP

char * ost::TCPStream::pbuf\fC [protected]\fP

\fBtimeout_t\fP ost::TCPStream::timeout\fC [protected]\fP

Author

Generated automatically by Doxygen for GNU CommonC++ from the source code.