1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
<HTML><HEAD><TITLE>TCPSession Class</TITLE></HEAD>
<BODY bgcolor="#ffffff">
<H1>TCPSession Class Reference</H1>
<p>
[<A HREF="index.html">APE Index</A>] [<A HREF="hier.html">APE Hierarchy</A>]
[<A HREF="header-list.html">Headers</A>]
</p>
<HR>
<P>Threaded socket with non-blocking constructor. <a href="#short">More...</a></P>
<P>
<code>
#include <<a href="socket-h.html">socket.h</a>>
</code>
</P>
<P>
Inherits: <a href="TCPSocket.html">TCPSocket</a>, <a href="Thread.html">Thread</a>
<P>
<H2>Public Members</H2>
<UL>
<LI> <b><a href="#ref0">TCPSession</a></b> (Semaphore *start, InetHostAddress &host, short port, int pri = 0, int stack = 0)
</LI>
<LI> <b><a href="#ref1">TCPSession</a></b> (Semaphore *start, TCPSocket &server, int pri = 0, int stack = 0)
</LI>
<LI> <b><a href="#ref2">TCPSession</a></b> (TCPSocket *server, Semaphore *start = NULL, int pri = 0, int stack = 0)
</LI>
</UL>
<H2>Protected Members</H2>
<UL>
<LI>int <b><a href="#ref3">WaitConnection</a></b> (timeout_t timeout)
</LI>
<LI>void <b><a href="#ref4">Initial</a></b> (void)
</LI>
<LI>void <b><a href="#ref5">Final</a></b> (void)
</LI>
</UL>
<HR>
<H2><a name="short">Detailed Description</a></H2>
<P>
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.
</P><HR>
<H3><b> <a name="ref0"></a><a name="TCPSession">TCPSession</a>(<a href="Semaphore.html">Semaphore</a> *start, <a href="InetHostAddress.html">InetHostAddress</a> &host, short port, int pri = 0, int stack = 0) </b><code>[public]</code></H3>
<p>Create a TCP socket that will be connected to a remote TCP
server and that will execute under it's own thread.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pri</td><td align="left" valign="top">
execution priority relative to parent.</td></tr>
<tr><td align="left" valign="top">
port</td><td align="left" valign="top">
number of remote server.</td></tr>
<tr><td align="left" valign="top">
stack</td><td align="left" valign="top">
allocation needed on some platforms.</td></tr>
<tr><td align="left" valign="top">
host</td><td align="left" valign="top">
internet address of remote TCP server.</td></tr>
<tr><td align="left" valign="top">
start</td><td align="left" valign="top">
semaphore as per Thread startup.</td></tr>
</table>
</dl>
<H3><b> <a name="ref1"></a><a name="TCPSession">TCPSession</a>(<a href="Semaphore.html">Semaphore</a> *start, <a href="TCPSocket.html">TCPSocket</a> &server, int pri = 0, int stack = 0) </b><code>[public]</code></H3>
<p>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.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pri</td><td align="left" valign="top">
execution priority relative to parent.</td></tr>
<tr><td align="left" valign="top">
stack</td><td align="left" valign="top">
allocation needed on some platforms.</td></tr>
<tr><td align="left" valign="top">
start</td><td align="left" valign="top">
semapore as per Thread startup.</td></tr>
<tr><td align="left" valign="top">
server</td><td align="left" valign="top">
tcp socket to accept a connection from.</td></tr>
</table>
</dl>
<H3><b> <a name="ref2"></a><a name="TCPSession">TCPSession</a>(<a href="TCPSocket.html">TCPSocket</a> *server, <a href="Semaphore.html">Semaphore</a> *start = NULL, int pri = 0, int stack = 0) </b><code>[public]</code></H3>
<p>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.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pri</td><td align="left" valign="top">
execution priority relative to parent.</td></tr>
<tr><td align="left" valign="top">
stack</td><td align="left" valign="top">
allocation needed on some platforms.</td></tr>
<tr><td align="left" valign="top">
start</td><td align="left" valign="top">
semaphore unless delayed start.</td></tr>
<tr><td align="left" valign="top">
server</td><td align="left" valign="top">
to accept connection from.</td></tr>
</table>
</dl>
<H3><b>int <a name="ref3"></a><a name="WaitConnection">WaitConnection</a>(timeout_t timeout) </b><code>[protected]</code></H3>
<p>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().
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
timeout</td><td align="left" valign="top">
to wait for completion in milliseconds.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
0 if successful, -1 if timed out.</dl>
<H3><b>void <a name="ref4"></a><a name="Initial">Initial</a>(void) </b><code>[protected]</code></H3>
<p>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.
</p>
<H3><b>void <a name="ref5"></a><a name="Final">Final</a>(void) </b><code>[protected]</code></H3>
<p>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.
</p>
<HR>
<TABLE WIDTH="100%"><TR><TD ALIGN="left" VALIGN="top">
<UL><LI><I>Author</I>: David Sugar <dyfet@ostel.com> </LI>
<LI>Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
</LI>
</UL></TD><TD ALIGN="RIGHT" VALIGN="TOP">
<b>K</b><i>doc</i>
</TD>
</TR></TABLE></BODY></HTML>
|