UCommon
Public Member Functions | Protected Member Functions | Protected Attributes
ucc::tcpstream Class Reference

Streamable tcp connection between client and server. More...

#include <stream.h>

Inheritance diagram for ucc::tcpstream:
Inheritance graph
[legend]
Collaboration diagram for ucc::tcpstream:
Collaboration graph
[legend]

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.
void open (const char *host, const char *service, unsigned segment=536)
 Open a stream connectoion to a host and service.
 operator bool () const
 See if stream connection is active.
bool operator! () const
 See if stream is disconnected.
 tcpstream (int family=PF_INET, timeout_t timeout=0)
 Create an unconnected tcp stream object that is idle until opened.
 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 (const TCPServer *server, unsigned segsize=536, timeout_t timeout=0)
 Create a stream from an existing tcp listener.
 tcpstream (const tcpstream &copy)
 Copy constructor...
virtual ~tcpstream ()
 Destroy a tcp stream.

Protected Member Functions

int _getch (void)
 This streambuf method is used to load the input buffer through the established tcp socket connection.
int _putch (int ch)
 This streambuf method is used to write the output buffer through the established tcp connection.
virtual ssize_t _read (char *buffer, size_t size)
virtual bool _wait (void)
virtual ssize_t _write (const char *buffer, size_t size)
socket_t getsocket (void) const
void release (void)
 Release the tcp stream and destroy the underlying socket.

Protected Attributes

socket_t so
timeout_t timeout

Detailed Description

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.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 109 of file stream.h.


Constructor & Destructor Documentation

ucc::tcpstream::tcpstream ( const tcpstream copy)

Copy constructor...

Parameters:
copyfor object.
ucc::tcpstream::tcpstream ( const TCPServer server,
unsigned  segsize = 536,
timeout_t  timeout = 0 
)

Create a stream from an existing tcp listener.

Parameters:
serverto accept connection from.
segsizefor tcp segments and buffering.
timeoutfor 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.

Parameters:
familyof protocol to create.
timeoutfor 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.

Parameters:
addressof service to connect to.
segsizefor tcp segments and buffering.
timeoutfor socket i/o operations.

Member Function Documentation

int ucc::tcpstream::_getch ( 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.

Implements ucc::CharacterProtocol.

int ucc::tcpstream::_putch ( int  ch) [protected, virtual]

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

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

Implements ucc::CharacterProtocol.

void ucc::tcpstream::close ( void  )

Close an active stream connection.

This does not release the socket but is a disconnect.

Reimplemented in ucc::sstream.

void ucc::tcpstream::open ( const char *  host,
const char *  service,
unsigned  segment = 536 
)

Open a stream connectoion to a host and service.

Parameters:
hostto connect to.
serviceto connect to by name or number as string.
segmentbuffering size to use.
void ucc::tcpstream::open ( Socket::address address,
unsigned  segment = 536 
)

Open a stream connection to a tcp service.

Parameters:
addressof service to access.
segmentbuffering size to use.
ucc::tcpstream::operator bool ( ) const [inline]

See if stream connection is active.

Returns:
true if stream is active.

Definition at line 190 of file stream.h.

bool ucc::tcpstream::operator! ( ) const [inline]

See if stream is disconnected.

Returns:
true if stream disconnected.

Definition at line 197 of file stream.h.


The documentation for this class was generated from the following file: