Google

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

TCPSession Class Reference

The TCP session is used to primarily to represent a client connection that can be managed on a seperate thread. Threaded streamable socket with non-blocking constructor. More...

#include <socket.h>

Inheritance diagram for TCPSession:

TCPStream Thread Socket streambuf iostream List of all members.

Public Methods

 TCPSession (Semaphore *start, const InetHostAddress &host, tpport_t port, int size = 512, int pri = 0, int stack = 0)
 Create a TCP socket that will be connected to a remote TCP server and that will execute under it's own thread. More...

 TCPSession (Semaphore *start, TCPSocket &server, int size = 512, int pri = 0, int stack = 0)
 Create a TCP socket from a bound TCP server by accepting a pending connection from that server and execute a thread for the accepted connection. More...


Protected Methods

int WaitConnection (timeout_t timeout = TIMEOUT_INF)
 Normally called during the thread Initial() method by default, this will wait for the socket connection to complete when connecting to a remote socket. More...

void Initial (void)
 The initial method is used to esablish a connection when delayed completion is used. More...

void Final (void)
 TCPSession derived objects can be freely created with "new" and safely terminate their "Run" method on their own by self-deleting when the thread terminates.


Detailed Description

The TCP session is used to primarily to represent a client connection that can be managed on a seperate thread. Threaded streamable socket with non-blocking constructor.

The TCP session also supports a non-blocking connection scheme which prevents blocking during the constructor and moving the process of completing a connection into the thread that executes for the session.

Author(s):
David Sugar <dyfet@ostel.com>


Constructor & Destructor Documentation

TCPSession::TCPSession ( Semaphore * start,
const InetHostAddress & host,
tpport_t port,
int size = 512,
int pri = 0,
int stack = 0 )
 

Create a TCP socket that will be connected to a remote TCP server and that will execute under it's own thread.

Parameters:
start   semaphore as per Thread startup.
host   internet address of remote TCP server.
port   number of remote server.
size   of streaming buffer.
pri   execution priority relative to parent.
stack   allocation needed on some platforms.

TCPSession::TCPSession ( Semaphore * start,
TCPSocket & server,
int size = 512,
int pri = 0,
int stack = 0 )
 

Create a TCP socket from a bound TCP server by accepting a pending connection from that server and execute a thread for the accepted connection.

Parameters:
start   semapore as per Thread startup.
server   tcp socket to accept a connection from.
size   of streaming buffer.
pri   execution priority relative to parent.
stack   allocation needed on some platforms.


Member Function Documentation

void TCPSession::Final ( void ) [inline, protected, virtual]
 

TCPSession derived objects can be freely created with "new" and safely terminate their "Run" method on their own by self-deleting when the thread terminates.

Reimplemented from Thread.

void TCPSession::Initial ( void ) [protected, virtual]
 

The initial method is used to esablish a connection when delayed completion is used.

This assures the constructor terminates without having to wait for a connection request to complete.

Reimplemented from Thread.

int TCPSession::WaitConnection ( timeout_t timeout = TIMEOUT_INF ) [protected]
 

Normally called during the thread Initial() method by default, this will wait for the socket connection to complete when connecting to a remote socket.

One might wish to use setCompletion() to change the socket back to blocking I/O calls after the connection completes. To implement the session one must create a derived class which implements Run().

Returns:
0 if successful, -1 if timed out.
Parameters:
timeout   to wait for completion in milliseconds.


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