Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > os > by-pkgid > 9c481c872fb0ae0cbadccdc2f4a18ab6 > files > 121

libasync-devel-0.17.0-5.fc14.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Async: AsyncTcpConnection.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.2-20100208 -->
<div class="navigation" id="top">
  <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><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_d583404e3b046262ade615a4e7154c3b.html">include</a>
  </div>
</div>
<div class="contents">
<h1>AsyncTcpConnection.h</h1><a href="AsyncTcpConnection_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef ASYNC_TCP_CONNECTION_INCLUDED</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define ASYNC_TCP_CONNECTION_INCLUDED</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="comment">/****************************************************************************</span>
<a name="l00037"></a>00037 <span class="comment"> *</span>
<a name="l00038"></a>00038 <span class="comment"> * System Includes</span>
<a name="l00039"></a>00039 <span class="comment"> *</span>
<a name="l00040"></a>00040 <span class="comment"> ****************************************************************************/</span>
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;sigc++/sigc++.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;stdint.h&gt;</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="comment">/****************************************************************************</span>
<a name="l00049"></a>00049 <span class="comment"> *</span>
<a name="l00050"></a>00050 <span class="comment"> * Project Includes</span>
<a name="l00051"></a>00051 <span class="comment"> *</span>
<a name="l00052"></a>00052 <span class="comment"> ****************************************************************************/</span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="preprocessor">#include &lt;<a class="code" href="AsyncIpAddress_8h.html" title="Platform independent representation of an IP address.">AsyncIpAddress.h</a>&gt;</span>
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="comment">/****************************************************************************</span>
<a name="l00058"></a>00058 <span class="comment"> *</span>
<a name="l00059"></a>00059 <span class="comment"> * Local Includes</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment"> ****************************************************************************/</span>
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="comment">/****************************************************************************</span>
<a name="l00066"></a>00066 <span class="comment"> *</span>
<a name="l00067"></a>00067 <span class="comment"> * Forward declarations</span>
<a name="l00068"></a>00068 <span class="comment"> *</span>
<a name="l00069"></a>00069 <span class="comment"> ****************************************************************************/</span>
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 <span class="comment">/****************************************************************************</span>
<a name="l00074"></a>00074 <span class="comment"> *</span>
<a name="l00075"></a>00075 <span class="comment"> * Namespace</span>
<a name="l00076"></a>00076 <span class="comment"> *</span>
<a name="l00077"></a>00077 <span class="comment"> ****************************************************************************/</span>
<a name="l00078"></a>00078 
<a name="l00079"></a>00079 <span class="keyword">namespace </span>Async
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081 
<a name="l00082"></a>00082 <span class="comment">/****************************************************************************</span>
<a name="l00083"></a>00083 <span class="comment"> *</span>
<a name="l00084"></a>00084 <span class="comment"> * Forward declarations of classes inside of the declared namespace</span>
<a name="l00085"></a>00085 <span class="comment"> *</span>
<a name="l00086"></a>00086 <span class="comment"> ****************************************************************************/</span>
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="keyword">class </span>FdWatch;
<a name="l00089"></a>00089 <span class="keyword">class </span>IpAddress;
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 <span class="comment">/****************************************************************************</span>
<a name="l00093"></a>00093 <span class="comment"> *</span>
<a name="l00094"></a>00094 <span class="comment"> * Defines &amp; typedefs</span>
<a name="l00095"></a>00095 <span class="comment"> *</span>
<a name="l00096"></a>00096 <span class="comment"> ****************************************************************************/</span>
<a name="l00097"></a>00097 
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <span class="comment">/****************************************************************************</span>
<a name="l00101"></a>00101 <span class="comment"> *</span>
<a name="l00102"></a>00102 <span class="comment"> * Exported Global Variables</span>
<a name="l00103"></a>00103 <span class="comment"> *</span>
<a name="l00104"></a>00104 <span class="comment"> ****************************************************************************/</span>
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="comment">/****************************************************************************</span>
<a name="l00109"></a>00109 <span class="comment"> *</span>
<a name="l00110"></a>00110 <span class="comment"> * Class definitions</span>
<a name="l00111"></a>00111 <span class="comment"> *</span>
<a name="l00112"></a>00112 <span class="comment"> ****************************************************************************/</span>
<a name="l00113"></a>00113 
<a name="l00123"></a><a class="code" href="classAsync_1_1TcpConnection.html">00123</a> <span class="keyword">class </span><a class="code" href="classAsync_1_1TcpConnection.html" title="A class for handling exiting TCP connections.">TcpConnection</a> : <span class="keyword">public</span> SigC::Object
<a name="l00124"></a>00124 {
<a name="l00125"></a>00125   <span class="keyword">public</span>:
<a name="l00129"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4">00129</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00130"></a>00130     { 
<a name="l00131"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a25cf1e053ea4081403543766b7f40a34">00131</a>       <a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a25cf1e053ea4081403543766b7f40a34" title="The specified host was not found in the DNS.">DR_HOST_NOT_FOUND</a>,       
<a name="l00132"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a79d43f05e692e509a417526564b8c252">00132</a>       <a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a79d43f05e692e509a417526564b8c252" title="The remote host disconnected.">DR_REMOTE_DISCONNECTED</a>,  
<a name="l00133"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a2c3f459bfc34d34b5a421a523ae83d69">00133</a>       <a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a2c3f459bfc34d34b5a421a523ae83d69" title="A system error occured (check errno).">DR_SYSTEM_ERROR</a>,         
<a name="l00134"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a8496d475658432471f6a9d9b0424d5ce">00134</a>       <a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a8496d475658432471f6a9d9b0424d5ce" title="Receiver buffer overflow.">DR_RECV_BUFFER_OVERFLOW</a>, 
<a name="l00135"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a8b97f3b0857415cc7ffad6620121c705">00135</a>       <a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4a8b97f3b0857415cc7ffad6620121c705" title="Disconnect ordered locally.">DR_ORDERED_DISCONNECT</a>    
<a name="l00136"></a>00136     } <a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4" title="Reason code for disconnects.">DisconnectReason</a>;
<a name="l00137"></a>00137     
<a name="l00141"></a><a class="code" href="classAsync_1_1TcpConnection.html#a27f6e87af1a6d57eb4e3eed7a9f73a7b">00141</a>     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classAsync_1_1TcpConnection.html#a27f6e87af1a6d57eb4e3eed7a9f73a7b" title="The default length of the reception buffer.">DEFAULT_RECV_BUF_LEN</a> = 1024;
<a name="l00142"></a>00142     
<a name="l00146"></a>00146     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classAsync_1_1TcpConnection.html#ab01a0120c01f97fa4ed8d935dbe4e291" title="Translate disconnect reason to a string.">disconnectReasonStr</a>(<a class="code" href="classAsync_1_1TcpConnection.html#a2a09caf85797c567d0cfce6f29ab9dd4" title="Reason code for disconnects.">DisconnectReason</a> reason);
<a name="l00147"></a>00147     
<a name="l00152"></a>00152     <span class="keyword">explicit</span> <a class="code" href="classAsync_1_1TcpConnection.html#ae638911f865af2d2ba71a02a5009c6da" title="Constructor.">TcpConnection</a>(<span class="keywordtype">size_t</span> recv_buf_len = <a class="code" href="classAsync_1_1TcpConnection.html#a27f6e87af1a6d57eb4e3eed7a9f73a7b" title="The default length of the reception buffer.">DEFAULT_RECV_BUF_LEN</a>);
<a name="l00153"></a>00153     
<a name="l00161"></a>00161     <a class="code" href="classAsync_1_1TcpConnection.html#ae638911f865af2d2ba71a02a5009c6da" title="Constructor.">TcpConnection</a>(<span class="keywordtype">int</span> sock, <span class="keyword">const</span> <a class="code" href="classAsync_1_1IpAddress.html" title="A class for representing an IP address in an OS independent way.">IpAddress</a>&amp; remote_addr,
<a name="l00162"></a>00162                   uint16_t remote_port,
<a name="l00163"></a>00163                   <span class="keywordtype">size_t</span> recv_buf_len = <a class="code" href="classAsync_1_1TcpConnection.html#a27f6e87af1a6d57eb4e3eed7a9f73a7b" title="The default length of the reception buffer.">DEFAULT_RECV_BUF_LEN</a>);
<a name="l00164"></a>00164     
<a name="l00168"></a>00168     <a class="code" href="classAsync_1_1TcpConnection.html#a2bc6a3b24ef293170ab97f3d36e128bd" title="Destructor.">~TcpConnection</a>(<span class="keywordtype">void</span>);
<a name="l00169"></a>00169     
<a name="l00177"></a>00177     <span class="keywordtype">void</span> <a class="code" href="classAsync_1_1TcpConnection.html#a31edfcb938751a142731bce63ace3412" title="Disconnect from the remote host.">disconnect</a>(<span class="keywordtype">void</span>);
<a name="l00178"></a>00178     
<a name="l00185"></a>00185     <span class="keywordtype">int</span> <a class="code" href="classAsync_1_1TcpConnection.html#a9c941f8e1ce95b2d6419f42b92cc32a6" title="Write data to the TCP connection.">write</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *buf, <span class="keywordtype">int</span> count);
<a name="l00186"></a>00186     
<a name="l00193"></a><a class="code" href="classAsync_1_1TcpConnection.html#a4072ea8aef1bdd369bacba2367e8660d">00193</a>     <span class="keyword">const</span> <a class="code" href="classAsync_1_1IpAddress.html" title="A class for representing an IP address in an OS independent way.">IpAddress</a>&amp; <a class="code" href="classAsync_1_1TcpConnection.html#a4072ea8aef1bdd369bacba2367e8660d" title="Return the IP-address of the remote host.">remoteHost</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> remote_addr; }
<a name="l00194"></a>00194     
<a name="l00199"></a><a class="code" href="classAsync_1_1TcpConnection.html#acc4f658b73f32acc85c79671c2f50676">00199</a>     uint16_t <a class="code" href="classAsync_1_1TcpConnection.html#acc4f658b73f32acc85c79671c2f50676" title="Return the remote port used.">remotePort</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> remote_port; }
<a name="l00200"></a>00200     
<a name="l00206"></a><a class="code" href="classAsync_1_1TcpConnection.html#a31240d2c61277733d4aff2723be6a3c8">00206</a>     <span class="keywordtype">bool</span> <a class="code" href="classAsync_1_1TcpConnection.html#a31240d2c61277733d4aff2723be6a3c8" title="Check if the connection is established or not.">isConnected</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> sock != -1; }
<a name="l00207"></a>00207     
<a name="l00213"></a><a class="code" href="classAsync_1_1TcpConnection.html#a839b134df486a7f756df660f84d1e2d1">00213</a>     SigC::Signal2&lt;void, TcpConnection *, DisconnectReason&gt; <a class="code" href="classAsync_1_1TcpConnection.html#a839b134df486a7f756df660f84d1e2d1" title="A signal that is emitted when a connection has been terminated.">disconnected</a>;
<a name="l00214"></a>00214     
<a name="l00229"></a><a class="code" href="classAsync_1_1TcpConnection.html#a833455297abb96d1f414bbeca7a19d96">00229</a>     SigC::Signal3&lt;int, TcpConnection *, void *, int&gt; <a class="code" href="classAsync_1_1TcpConnection.html#a833455297abb96d1f414bbeca7a19d96" title="A signal that is emitted when data has been received on the connection.">dataReceived</a>;
<a name="l00230"></a>00230     
<a name="l00236"></a><a class="code" href="classAsync_1_1TcpConnection.html#a2a52cdcd8adf4bdb744d28931ef97075">00236</a>     SigC::Signal1&lt;void, bool&gt; <a class="code" href="classAsync_1_1TcpConnection.html#a2a52cdcd8adf4bdb744d28931ef97075" title="A signal that is emitted when the send buffer status changes.">sendBufferFull</a>;
<a name="l00237"></a>00237 
<a name="l00238"></a>00238         
<a name="l00239"></a>00239   <span class="keyword">protected</span>:
<a name="l00246"></a>00246     <span class="keywordtype">void</span> <a class="code" href="classAsync_1_1TcpConnection.html#a4b31bcdba063384b6059acea4f698703" title="Setup information about the connection.">setSocket</a>(<span class="keywordtype">int</span> sock);
<a name="l00247"></a>00247     
<a name="l00254"></a>00254     <span class="keywordtype">void</span> <a class="code" href="classAsync_1_1TcpConnection.html#af7a3e875db395126cc82ab5fe70f6f5d" title="Setup information about the connection.">setRemoteAddr</a>(<span class="keyword">const</span> <a class="code" href="classAsync_1_1IpAddress.html" title="A class for representing an IP address in an OS independent way.">IpAddress</a>&amp; remote_addr);
<a name="l00255"></a>00255     
<a name="l00262"></a>00262     <span class="keywordtype">void</span> <a class="code" href="classAsync_1_1TcpConnection.html#a8d1e774ff805f4aa4eaa618bfd3d19d4" title="Setup information about the connection.">setRemotePort</a>(uint16_t remote_port);
<a name="l00263"></a>00263     
<a name="l00271"></a><a class="code" href="classAsync_1_1TcpConnection.html#a4b8420a87eaf51a479b3134ce4591908">00271</a>     <span class="keywordtype">int</span> <a class="code" href="classAsync_1_1TcpConnection.html#a4b8420a87eaf51a479b3134ce4591908" title="Return the socket file descriptor.">socket</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> sock; }
<a name="l00272"></a>00272     
<a name="l00273"></a>00273     
<a name="l00274"></a>00274   <span class="keyword">private</span>:
<a name="l00275"></a>00275     <a class="code" href="classAsync_1_1IpAddress.html" title="A class for representing an IP address in an OS independent way.">IpAddress</a> remote_addr;
<a name="l00276"></a>00276     uint16_t  remote_port;
<a name="l00277"></a>00277     <span class="keywordtype">size_t</span>    recv_buf_len;
<a name="l00278"></a>00278     <span class="keywordtype">int</span>       sock;
<a name="l00279"></a>00279     <a class="code" href="classAsync_1_1FdWatch.html" title="A class for watching file descriptors.">FdWatch</a> * rd_watch;
<a name="l00280"></a>00280     <a class="code" href="classAsync_1_1FdWatch.html" title="A class for watching file descriptors.">FdWatch</a> * wr_watch;
<a name="l00281"></a>00281     <span class="keywordtype">char</span> *    recv_buf;
<a name="l00282"></a>00282     <span class="keywordtype">size_t</span>    recv_buf_cnt;
<a name="l00283"></a>00283     
<a name="l00284"></a>00284     <span class="keywordtype">void</span> recvHandler(<a class="code" href="classAsync_1_1FdWatch.html" title="A class for watching file descriptors.">FdWatch</a> *watch);
<a name="l00285"></a>00285     <span class="keywordtype">void</span> writeHandler(<a class="code" href="classAsync_1_1FdWatch.html" title="A class for watching file descriptors.">FdWatch</a> *watch);
<a name="l00286"></a>00286 
<a name="l00287"></a>00287 };  <span class="comment">/* class TcpConnection */</span>
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 
<a name="l00290"></a>00290 } <span class="comment">/* namespace */</span>
<a name="l00291"></a>00291 
<a name="l00292"></a>00292 <span class="preprocessor">#endif </span><span class="comment">/* ASYNC_TCP_CONNECTION_INCLUDED */</span>
<a name="l00293"></a>00293 
<a name="l00294"></a>00294 
<a name="l00295"></a>00295 
<a name="l00296"></a>00296 <span class="comment">/*</span>
<a name="l00297"></a>00297 <span class="comment"> * This file has not been truncated</span>
<a name="l00298"></a>00298 <span class="comment"> */</span>
<a name="l00299"></a>00299 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address>
</body>
</html>