TCPSession Class Reference

[APE Index] [APE Hierarchy] [Headers]


Threaded socket with non-blocking constructor. More...

#include <socket.h>

Inherits: TCPSocket, Thread

Public Members

Protected Members


Detailed Description

The TCP session is used to primarily to represent a client connection that can be managed on a seperate thread. 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.


TCPSession(Semaphore *start, InetHostAddress &host, short port, int pri = 0, int stack = 0) [public]

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

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

TCPSession(Semaphore *start, TCPSocket &server, int pri = 0, int stack = 0) [public]

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:
pri execution priority relative to parent.
stack allocation needed on some platforms.
start semapore as per Thread startup.
server tcp socket to accept a connection from.

TCPSession(TCPSocket *server, Semaphore *start = NULL, int pri = 0, int stack = 0) [public]

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

Parameters:
pri execution priority relative to parent.
stack allocation needed on some platforms.
start semaphore unless delayed start.
server to accept connection from.

int WaitConnection(timeout_t timeout) [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().

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

void Initial(void) [protected]

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.

void Final(void) [protected]

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.


  • Author: David Sugar <dyfet@ostel.com>
  • Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
Kdoc