Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 314

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>GNU CommonC++: ost::TCPSession Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li id="current"><a href="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_t_c_p_session.html">TCPSession</a></div>
<h1>ost::TCPSession Class Reference</h1><!-- doxytag: class="ost::TCPSession" --><!-- doxytag: inherits="ost::Thread,ost::TCPStream" -->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.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="socket_8h-source.html">socket.h</a>&gt;</code>
<p>
<p>Inheritance diagram for ost::TCPSession:
<p><center><img src="classost_1_1_t_c_p_session.png" usemap="#ost::TCPSession_map" border="0" alt=""></center>
<map name="ost::TCPSession_map">
<area href="classost_1_1_thread.html" alt="ost::Thread" shape="rect" coords="0,56,102,80">
<area href="classost_1_1_t_c_p_stream.html" alt="ost::TCPStream" shape="rect" coords="112,56,214,80">
<area href="classost_1_1_socket.html" alt="ost::Socket" shape="rect" coords="112,0,214,24">
</map>
<a href="classost_1_1_t_c_p_session-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#70bc06626fdd05d061772794255f64e7">TCPSession</a> (const <a class="el" href="classost_1_1_i_p_v4_host.html">IPV4Host</a> &amp;host, <a class="el" href="namespaceost.html#3c74a1a40c359fd349f3e3e1b96ebfc7">tpport_t</a> port, size_t size=536, int pri=0, size_t stack=0)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a TCP socket that will be connected to a remote TCP server and that will execute under it's own thread.  <a href="#70bc06626fdd05d061772794255f64e7"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#4d3b25b7a96a1ea0115182740096b824">TCPSession</a> (const <a class="el" href="classost_1_1_i_p_v6_host.html">IPV6Host</a> &amp;host, <a class="el" href="namespaceost.html#3c74a1a40c359fd349f3e3e1b96ebfc7">tpport_t</a> port, size_t size=536, int pri=0, size_t stack=0)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#25cbaa17d60d4dc693bf48bd36933231">TCPSession</a> (<a class="el" href="classost_1_1_t_c_p_socket.html">TCPSocket</a> &amp;server, int pri=0, size_t stack=0)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">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.  <a href="#25cbaa17d60d4dc693bf48bd36933231"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#f6d0c9073780fd0549b79c1131fec04f">TCPSession</a> (<a class="el" href="classost_1_1_t_c_p_v6_socket.html">TCPV6Socket</a> &amp;server, int pri=0, size_t stack=0)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#4d5b8693e78bab5c68c2e8ea1c2c024c">~TCPSession</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Make sure destruction happens through a virtual.  <a href="#4d5b8693e78bab5c68c2e8ea1c2c024c"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#fed206d2ae166a3f40dbea3eab924a34">waitConnection</a> (<a class="el" href="thread_8h.html#f412159e5cef839836a5e7b19ee75d1c">timeout_t</a> <a class="el" href="classost_1_1_t_c_p_stream.html#e223ae380e2dc9d2e64cde0a577eccf2">timeout</a>=TIMEOUT_INF)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Normally called during the thread Initial() method by default, this will wait for the socket connection to complete when connecting to a remote socket.  <a href="#fed206d2ae166a3f40dbea3eab924a34"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_t_c_p_session.html#d0a0568018d48cc3079222156a6af093">initial</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The initial method is used to esablish a connection when delayed completion is used.  <a href="#d0a0568018d48cc3079222156a6af093"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
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. 
<p>
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>
<dl compact><dt><b>Author:</b></dt><dd>David Sugar &lt;<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>&gt; </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>

<p>
<a class="el" href="tcpthread_8cpp-example.html#_a78">tcpthread.cpp</a>.</dl>
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="70bc06626fdd05d061772794255f64e7"></a><!-- doxytag: member="ost::TCPSession::TCPSession" ref="70bc06626fdd05d061772794255f64e7" args="(const IPV4Host &amp;host, tpport_t port, size_t size=536, int pri=0, size_t stack=0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::TCPSession::TCPSession           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="classost_1_1_i_p_v4_host.html">IPV4Host</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>host</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap><a class="el" href="namespaceost.html#3c74a1a40c359fd349f3e3e1b96ebfc7">tpport_t</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>port</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname" nowrap> <em>size</em> = <code>536</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>pri</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname" nowrap> <em>stack</em> = <code>0</code></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Create a TCP socket that will be connected to a remote TCP server and that will execute under it's own thread. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>host</em>&nbsp;</td><td>internet address of remote TCP server. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>port</em>&nbsp;</td><td>number of remote server. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>size</em>&nbsp;</td><td>of streaming buffer. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>pri</em>&nbsp;</td><td>execution priority relative to parent. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>stack</em>&nbsp;</td><td>allocation needed on some platforms. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="4d3b25b7a96a1ea0115182740096b824"></a><!-- doxytag: member="ost::TCPSession::TCPSession" ref="4d3b25b7a96a1ea0115182740096b824" args="(const IPV6Host &amp;host, tpport_t port, size_t size=536, int pri=0, size_t stack=0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::TCPSession::TCPSession           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="classost_1_1_i_p_v6_host.html">IPV6Host</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>host</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap><a class="el" href="namespaceost.html#3c74a1a40c359fd349f3e3e1b96ebfc7">tpport_t</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>port</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname" nowrap> <em>size</em> = <code>536</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>pri</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname" nowrap> <em>stack</em> = <code>0</code></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<a class="anchor" name="25cbaa17d60d4dc693bf48bd36933231"></a><!-- doxytag: member="ost::TCPSession::TCPSession" ref="25cbaa17d60d4dc693bf48bd36933231" args="(TCPSocket &amp;server, int pri=0, size_t stack=0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::TCPSession::TCPSession           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_t_c_p_socket.html">TCPSocket</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>server</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>pri</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname" nowrap> <em>stack</em> = <code>0</code></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<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>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>server</em>&nbsp;</td><td>tcp socket to accept a connection from. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>pri</em>&nbsp;</td><td>execution priority relative to parent. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>stack</em>&nbsp;</td><td>allocation needed on some platforms. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="f6d0c9073780fd0549b79c1131fec04f"></a><!-- doxytag: member="ost::TCPSession::TCPSession" ref="f6d0c9073780fd0549b79c1131fec04f" args="(TCPV6Socket &amp;server, int pri=0, size_t stack=0)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::TCPSession::TCPSession           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_t_c_p_v6_socket.html">TCPV6Socket</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>server</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>int&nbsp;</td>
          <td class="mdname" nowrap> <em>pri</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>size_t&nbsp;</td>
          <td class="mdname" nowrap> <em>stack</em> = <code>0</code></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<a class="anchor" name="4d5b8693e78bab5c68c2e8ea1c2c024c"></a><!-- doxytag: member="ost::TCPSession::~TCPSession" ref="4d5b8693e78bab5c68c2e8ea1c2c024c" args="()" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">virtual ost::TCPSession::~TCPSession           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Make sure destruction happens through a virtual. 
<p>
..     </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="d0a0568018d48cc3079222156a6af093"></a><!-- doxytag: member="ost::TCPSession::initial" ref="d0a0568018d48cc3079222156a6af093" args="(void)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::TCPSession::initial           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected, virtual]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The initial method is used to esablish a connection when delayed completion is used. 
<p>
This assures the constructor terminates without having to wait for a connection request to complete. 
<p>
Reimplemented from <a class="el" href="classost_1_1_thread.html#300c229e76725eeddc69867f7ecea91f">ost::Thread</a>.    </td>
  </tr>
</table>
<a class="anchor" name="fed206d2ae166a3f40dbea3eab924a34"></a><!-- doxytag: member="ost::TCPSession::waitConnection" ref="fed206d2ae166a3f40dbea3eab924a34" args="(timeout_t timeout=TIMEOUT_INF)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">int ost::TCPSession::waitConnection           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="thread_8h.html#f412159e5cef839836a5e7b19ee75d1c">timeout_t</a>&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>timeout</em> = <code>TIMEOUT_INF</code>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [protected]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<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. 
<p>
One might wish to use <a class="el" href="classost_1_1_socket.html#16eb72794ce956b2af6b935eb59b2e24">setCompletion()</a> 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 <a class="el" href="classost_1_1_thread.html#dd7d339d94b8a1ed2b2b0324a95b7e74">run()</a>.<p>
<dl compact><dt><b>Returns:</b></dt><dd>0 if successful, -1 if timed out. </dd></dl>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>to wait for completion in milliseconds. </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="socket_8h-source.html">socket.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 19 10:50:57 2006 for GNU CommonC++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>