Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 23e07fd43e778a61ff4b78161a3e2389 > files > 1874

cryptopp-doc-5.6.1-5.fc14.noarch.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>Crypto++: network.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.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Crypto++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;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>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">network.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_NETWORK_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_NETWORK_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;config.h&quot;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#ifdef HIGHRES_TIMER_AVAILABLE</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="filters_8h.html">filters.h</a>&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;hrtimer.h&quot;</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;deque&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 NAMESPACE_BEGIN(CryptoPP)
<a name="l00014"></a>00014 
<a name="l00015"></a><a class="code" href="class_limited_bandwidth.html">00015</a> class <a class="code" href="class_limited_bandwidth.html">LimitedBandwidth</a>
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017 <span class="keyword">public</span>:
<a name="l00018"></a>00018         LimitedBandwidth(lword maxBytesPerSecond = 0)
<a name="l00019"></a>00019                 : m_maxBytesPerSecond(maxBytesPerSecond), m_timer(Timer::MILLISECONDS)
<a name="l00020"></a>00020                 , m_nextTransceiveTime(0)
<a name="l00021"></a>00021                 { m_timer.StartTimer(); }
<a name="l00022"></a>00022 
<a name="l00023"></a>00023         lword GetMaxBytesPerSecond()<span class="keyword"> const</span>
<a name="l00024"></a>00024 <span class="keyword">                </span>{ <span class="keywordflow">return</span> m_maxBytesPerSecond; }
<a name="l00025"></a>00025 
<a name="l00026"></a>00026         <span class="keywordtype">void</span> SetMaxBytesPerSecond(lword v)
<a name="l00027"></a>00027                 { m_maxBytesPerSecond = v; }
<a name="l00028"></a>00028 
<a name="l00029"></a>00029         lword ComputeCurrentTransceiveLimit();
<a name="l00030"></a>00030 
<a name="l00031"></a>00031         <span class="keywordtype">double</span> TimeToNextTransceive();
<a name="l00032"></a>00032 
<a name="l00033"></a>00033         <span class="keywordtype">void</span> NoteTransceive(lword size);
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00036"></a>00036 <span class="comment">        /*! GetWaitObjects() must be called despite the 0 return from GetMaxWaitObjectCount();</span>
<a name="l00037"></a>00037 <span class="comment">            the 0 is because the ScheduleEvent() method is used instead of adding a wait object */</span>
<a name="l00038"></a><a class="code" href="class_limited_bandwidth.html#ad3f925ef7f2a9db58b8840f8a4f1f0cb">00038</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_limited_bandwidth.html#ad3f925ef7f2a9db58b8840f8a4f1f0cb">GetMaxWaitObjectCount</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 0; }
<a name="l00039"></a>00039         <span class="keywordtype">void</span> GetWaitObjects(<a class="code" href="class_wait_object_container.html" title="container of wait objects">WaitObjectContainer</a> &amp;container, <span class="keyword">const</span> <a class="code" href="class_call_stack.html">CallStack</a> &amp;callStack);
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="keyword">private</span>:        
<a name="l00042"></a>00042         lword m_maxBytesPerSecond;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044         <span class="keyword">typedef</span> std::deque&lt;std::pair&lt;double, lword&gt; &gt; OpQueue;
<a name="l00045"></a>00045         OpQueue m_ops;
<a name="l00046"></a>00046 
<a name="l00047"></a>00047         <a class="code" href="class_timer.html" title="high resolution timer">Timer</a> m_timer;
<a name="l00048"></a>00048         <span class="keywordtype">double</span> m_nextTransceiveTime;
<a name="l00049"></a>00049 
<a name="l00050"></a>00050         <span class="keywordtype">void</span> ComputeNextTransceiveTime();
<a name="l00051"></a>00051         <span class="keywordtype">double</span> GetCurTimeAndCleanUp();
<a name="l00052"></a>00052 };
<a name="l00053"></a>00053 <span class="comment"></span>
<a name="l00054"></a>00054 <span class="comment">//! a Source class that can pump from a device for a specified amount of time.</span>
<a name="l00055"></a><a class="code" href="class_nonblocking_source.html">00055</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_nonblocking_source.html" title="a Source class that can pump from a device for a specified amount of time.">NonblockingSource</a> : <span class="keyword">public</span> <a class="code" href="class_auto_signaling.html" title="_">AutoSignaling</a>&lt;Source&gt;, <span class="keyword">public</span> <a class="code" href="class_limited_bandwidth.html">LimitedBandwidth</a>
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 <span class="keyword">public</span>:
<a name="l00058"></a>00058         <a class="code" href="class_nonblocking_source.html" title="a Source class that can pump from a device for a specified amount of time.">NonblockingSource</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment)
<a name="l00059"></a>00059                 : m_messageEndSent(<span class="keyword">false</span>) , m_doPumpBlocked(<span class="keyword">false</span>), m_blockedBySpeedLimit(<span class="keyword">false</span>) {Detach(attachment);}
<a name="l00060"></a>00060 <span class="comment"></span>
<a name="l00061"></a>00061 <span class="comment">        //!     \name NONBLOCKING SOURCE</span>
<a name="l00062"></a>00062 <span class="comment"></span><span class="comment">        //@{</span>
<a name="l00063"></a>00063 <span class="comment"></span><span class="comment"></span>
<a name="l00064"></a>00064 <span class="comment">        //! pump up to maxSize bytes using at most maxTime milliseconds</span>
<a name="l00065"></a>00065 <span class="comment"></span><span class="comment">        /*! If checkDelimiter is true, pump up to delimiter, which itself is not extracted or pumped. */</span>
<a name="l00066"></a>00066         <span class="keywordtype">size_t</span> GeneralPump2(lword &amp;byteCount, <span class="keywordtype">bool</span> blockingOutput=<span class="keyword">true</span>, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime=<a class="code" href="cryptlib_8h.html#a5dc7a255dd813433eeee3152544c2f1d" title="used to represent infinite time">INFINITE_TIME</a>, <span class="keywordtype">bool</span> checkDelimiter=<span class="keyword">false</span>, byte delimiter=<span class="charliteral">&#39;\n&#39;</span>);
<a name="l00067"></a>00067 
<a name="l00068"></a>00068         lword GeneralPump(lword maxSize=LWORD_MAX, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime=<a class="code" href="cryptlib_8h.html#a5dc7a255dd813433eeee3152544c2f1d" title="used to represent infinite time">INFINITE_TIME</a>, <span class="keywordtype">bool</span> checkDelimiter=<span class="keyword">false</span>, byte delimiter=<span class="charliteral">&#39;\n&#39;</span>)
<a name="l00069"></a>00069         {
<a name="l00070"></a>00070                 GeneralPump2(maxSize, <span class="keyword">true</span>, maxTime, checkDelimiter, delimiter);
<a name="l00071"></a>00071                 <span class="keywordflow">return</span> maxSize;
<a name="l00072"></a>00072         }
<a name="l00073"></a>00073         lword TimedPump(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime)
<a name="l00074"></a>00074                 {<span class="keywordflow">return</span> GeneralPump(LWORD_MAX, maxTime);}
<a name="l00075"></a>00075         lword PumpLine(byte delimiter=<span class="charliteral">&#39;\n&#39;</span>, lword maxSize=1024)
<a name="l00076"></a>00076                 {<span class="keywordflow">return</span> GeneralPump(maxSize, <a class="code" href="cryptlib_8h.html#a5dc7a255dd813433eeee3152544c2f1d" title="used to represent infinite time">INFINITE_TIME</a>, <span class="keyword">true</span>, delimiter);}
<a name="l00077"></a>00077 
<a name="l00078"></a>00078         <span class="keywordtype">size_t</span> Pump2(lword &amp;byteCount, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>)
<a name="l00079"></a>00079                 {<span class="keywordflow">return</span> GeneralPump2(byteCount, blocking, blocking ? <a class="code" href="cryptlib_8h.html#a5dc7a255dd813433eeee3152544c2f1d" title="used to represent infinite time">INFINITE_TIME</a> : 0);}
<a name="l00080"></a>00080         <span class="keywordtype">size_t</span> PumpMessages2(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> &amp;messageCount, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>);<span class="comment"></span>
<a name="l00081"></a>00081 <span class="comment">        //@}</span>
<a name="l00082"></a>00082 <span class="comment"></span>
<a name="l00083"></a>00083 <span class="keyword">protected</span>:
<a name="l00084"></a>00084         <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> DoPump(lword &amp;byteCount, <span class="keywordtype">bool</span> blockingOutput,
<a name="l00085"></a>00085                 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime, <span class="keywordtype">bool</span> checkDelimiter, byte delimiter) =0;
<a name="l00086"></a>00086 
<a name="l00087"></a>00087         <span class="keywordtype">bool</span> BlockedBySpeedLimit()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_blockedBySpeedLimit; }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 <span class="keyword">private</span>:
<a name="l00090"></a>00090         <span class="keywordtype">bool</span> m_messageEndSent, m_doPumpBlocked, m_blockedBySpeedLimit;
<a name="l00091"></a>00091 };
<a name="l00092"></a>00092 <span class="comment"></span>
<a name="l00093"></a>00093 <span class="comment">//! Network Receiver</span>
<a name="l00094"></a><a class="code" href="class_network_receiver.html">00094</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_network_receiver.html" title="Network Receiver.">NetworkReceiver</a> : <span class="keyword">public</span> <a class="code" href="class_waitable.html" title="interface for objects that you can wait for">Waitable</a>
<a name="l00095"></a>00095 {
<a name="l00096"></a>00096 <span class="keyword">public</span>:
<a name="l00097"></a>00097         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> MustWaitToReceive() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00098"></a>00098         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> MustWaitForResult() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}<span class="comment"></span>
<a name="l00099"></a>00099 <span class="comment">        //! receive data from network source, returns whether result is immediately available</span>
<a name="l00100"></a>00100 <span class="comment"></span>        <span class="keyword">virtual</span> <span class="keywordtype">bool</span> Receive(byte* buf, <span class="keywordtype">size_t</span> bufLen) =0;
<a name="l00101"></a>00101         <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetReceiveResult() =0;
<a name="l00102"></a>00102         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> EofReceived() <span class="keyword">const</span> =0;
<a name="l00103"></a>00103 };
<a name="l00104"></a>00104 
<a name="l00105"></a><a class="code" href="class_nonblocking_sink_info.html">00105</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_nonblocking_sink_info.html">NonblockingSinkInfo</a>
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 <span class="keyword">public</span>:
<a name="l00108"></a>00108         <span class="keyword">virtual</span> ~<a class="code" href="class_nonblocking_sink_info.html">NonblockingSinkInfo</a>() {}
<a name="l00109"></a>00109         <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> GetMaxBufferSize() <span class="keyword">const</span> =0;
<a name="l00110"></a>00110         <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> GetCurrentBufferSize() <span class="keyword">const</span> =0;
<a name="l00111"></a>00111         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> EofPending() <span class="keyword">const</span> =0;<span class="comment"></span>
<a name="l00112"></a>00112 <span class="comment">        //! compute the current speed of this sink in bytes per second</span>
<a name="l00113"></a>00113 <span class="comment"></span>        <span class="keyword">virtual</span> <span class="keywordtype">float</span> ComputeCurrentSpeed() =0;<span class="comment"></span>
<a name="l00114"></a>00114 <span class="comment">        //! get the maximum observed speed of this sink in bytes per second</span>
<a name="l00115"></a>00115 <span class="comment"></span>        <span class="keyword">virtual</span> <span class="keywordtype">float</span> GetMaxObservedSpeed() <span class="keyword">const</span> =0;
<a name="l00116"></a>00116 };
<a name="l00117"></a>00117 <span class="comment"></span>
<a name="l00118"></a>00118 <span class="comment">//! a Sink class that queues input and can flush to a device for a specified amount of time.</span>
<a name="l00119"></a><a class="code" href="class_nonblocking_sink.html">00119</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_nonblocking_sink.html" title="a Sink class that queues input and can flush to a device for a specified amount of time...">NonblockingSink</a> : <span class="keyword">public</span> <a class="code" href="class_sink.html" title="A BufferedTransformation that doesn&#39;t produce any retrievable output.">Sink</a>, <span class="keyword">public</span> <a class="code" href="class_nonblocking_sink_info.html">NonblockingSinkInfo</a>, <span class="keyword">public</span> <a class="code" href="class_limited_bandwidth.html">LimitedBandwidth</a>
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121 <span class="keyword">public</span>:
<a name="l00122"></a>00122         <a class="code" href="class_nonblocking_sink.html" title="a Sink class that queues input and can flush to a device for a specified amount of time...">NonblockingSink</a>() : m_blockedBySpeedLimit(<span class="keyword">false</span>) {}
<a name="l00123"></a>00123 
<a name="l00124"></a>00124         <span class="keywordtype">bool</span> IsolatedFlush(<span class="keywordtype">bool</span> hardFlush, <span class="keywordtype">bool</span> blocking);
<a name="l00125"></a>00125 <span class="comment"></span>
<a name="l00126"></a>00126 <span class="comment">        //! flush to device for no more than maxTime milliseconds</span>
<a name="l00127"></a>00127 <span class="comment"></span><span class="comment">        /*! This function will repeatedly attempt to flush data to some device, until</span>
<a name="l00128"></a>00128 <span class="comment">                the queue is empty, or a total of maxTime milliseconds have elapsed.</span>
<a name="l00129"></a>00129 <span class="comment">                If maxTime == 0, at least one attempt will be made to flush some data, but</span>
<a name="l00130"></a>00130 <span class="comment">                it is likely that not all queued data will be flushed, even if the device</span>
<a name="l00131"></a>00131 <span class="comment">                is ready to receive more data without waiting. If you want to flush as much data</span>
<a name="l00132"></a>00132 <span class="comment">                as possible without waiting for the device, call this function in a loop.</span>
<a name="l00133"></a>00133 <span class="comment">                For example: while (sink.TimedFlush(0) &gt; 0) {}</span>
<a name="l00134"></a>00134 <span class="comment">                \return number of bytes flushed</span>
<a name="l00135"></a>00135 <span class="comment">        */</span>
<a name="l00136"></a>00136         lword TimedFlush(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime, <span class="keywordtype">size_t</span> targetSize = 0);
<a name="l00137"></a>00137 
<a name="l00138"></a>00138         <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetMaxBufferSize(<span class="keywordtype">size_t</span> maxBufferSize) =0;<span class="comment"></span>
<a name="l00139"></a>00139 <span class="comment">        //! set a bound which will cause sink to flush if exceeded by GetCurrentBufferSize()</span>
<a name="l00140"></a>00140 <span class="comment"></span>        <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetAutoFlushBound(<span class="keywordtype">size_t</span> bound) =0;
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 <span class="keyword">protected</span>:
<a name="l00143"></a>00143         <span class="keyword">virtual</span> lword DoFlush(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime, <span class="keywordtype">size_t</span> targetSize) = 0;
<a name="l00144"></a>00144 
<a name="l00145"></a>00145         <span class="keywordtype">bool</span> BlockedBySpeedLimit()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_blockedBySpeedLimit; }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 <span class="keyword">private</span>:
<a name="l00148"></a>00148         <span class="keywordtype">bool</span> m_blockedBySpeedLimit;
<a name="l00149"></a>00149 };
<a name="l00150"></a>00150 <span class="comment"></span>
<a name="l00151"></a>00151 <span class="comment">//! Network Sender</span>
<a name="l00152"></a><a class="code" href="class_network_sender.html">00152</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_network_sender.html" title="Network Sender.">NetworkSender</a> : <span class="keyword">public</span> <a class="code" href="class_waitable.html" title="interface for objects that you can wait for">Waitable</a>
<a name="l00153"></a>00153 {
<a name="l00154"></a>00154 <span class="keyword">public</span>:
<a name="l00155"></a>00155         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> MustWaitToSend() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00156"></a>00156         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> MustWaitForResult() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00157"></a>00157         <span class="keyword">virtual</span> <span class="keywordtype">void</span> Send(<span class="keyword">const</span> byte* buf, <span class="keywordtype">size_t</span> bufLen) =0;
<a name="l00158"></a>00158         <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetSendResult() =0;
<a name="l00159"></a>00159         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> MustWaitForEof() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00160"></a>00160         <span class="keyword">virtual</span> <span class="keywordtype">void</span> SendEof() =0;
<a name="l00161"></a>00161         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> EofSent() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}  <span class="comment">// implement if MustWaitForEof() == true</span>
<a name="l00162"></a>00162 };
<a name="l00163"></a>00163 <span class="comment"></span>
<a name="l00164"></a>00164 <span class="comment">//! Network Source</span>
<a name="l00165"></a><a class="code" href="class_network_source.html">00165</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_network_source.html" title="Network Source.">NetworkSource</a> : <span class="keyword">public</span> <a class="code" href="class_nonblocking_source.html" title="a Source class that can pump from a device for a specified amount of time.">NonblockingSource</a>
<a name="l00166"></a>00166 {
<a name="l00167"></a>00167 <span class="keyword">public</span>:
<a name="l00168"></a>00168         <a class="code" href="class_network_source.html" title="Network Source.">NetworkSource</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment);
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_limited_bandwidth.html#ad3f925ef7f2a9db58b8840f8a4f1f0cb">GetMaxWaitObjectCount</a>() <span class="keyword">const</span>;
<a name="l00171"></a>00171         <span class="keywordtype">void</span> GetWaitObjects(<a class="code" href="class_wait_object_container.html" title="container of wait objects">WaitObjectContainer</a> &amp;container, <a class="code" href="class_call_stack.html">CallStack</a> <span class="keyword">const</span>&amp; callStack);
<a name="l00172"></a>00172 
<a name="l00173"></a>00173         <span class="keywordtype">bool</span> SourceExhausted()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_dataBegin == m_dataEnd &amp;&amp; GetReceiver().EofReceived();}
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 <span class="keyword">protected</span>:
<a name="l00176"></a>00176         <span class="keywordtype">size_t</span> DoPump(lword &amp;byteCount, <span class="keywordtype">bool</span> blockingOutput, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime, <span class="keywordtype">bool</span> checkDelimiter, byte delimiter);
<a name="l00177"></a>00177 
<a name="l00178"></a>00178         <span class="keyword">virtual</span> <a class="code" href="class_network_receiver.html" title="Network Receiver.">NetworkReceiver</a> &amp; AccessReceiver() =0;
<a name="l00179"></a>00179         <span class="keyword">const</span> <a class="code" href="class_network_receiver.html" title="Network Receiver.">NetworkReceiver</a> &amp; GetReceiver()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">const_cast&lt;</span><a class="code" href="class_network_source.html" title="Network Source.">NetworkSource</a> *<span class="keyword">&gt;</span>(<span class="keyword">this</span>)-&gt;AccessReceiver();}
<a name="l00180"></a>00180 
<a name="l00181"></a>00181 <span class="keyword">private</span>:
<a name="l00182"></a>00182         <a class="code" href="class_sec_block.html">SecByteBlock</a> m_buf;
<a name="l00183"></a>00183         <span class="keywordtype">size_t</span> m_putSize, m_dataBegin, m_dataEnd;
<a name="l00184"></a>00184         <span class="keywordtype">bool</span> m_waitingForResult, m_outputBlocked;
<a name="l00185"></a>00185 };
<a name="l00186"></a>00186 <span class="comment"></span>
<a name="l00187"></a>00187 <span class="comment">//! Network Sink</span>
<a name="l00188"></a><a class="code" href="class_network_sink.html">00188</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_network_sink.html" title="Network Sink.">NetworkSink</a> : <span class="keyword">public</span> <a class="code" href="class_nonblocking_sink.html" title="a Sink class that queues input and can flush to a device for a specified amount of time...">NonblockingSink</a>
<a name="l00189"></a>00189 {
<a name="l00190"></a>00190 <span class="keyword">public</span>:
<a name="l00191"></a>00191         <a class="code" href="class_network_sink.html" title="Network Sink.">NetworkSink</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxBufferSize, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> autoFlushBound);
<a name="l00192"></a>00192 
<a name="l00193"></a>00193         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_limited_bandwidth.html#ad3f925ef7f2a9db58b8840f8a4f1f0cb">GetMaxWaitObjectCount</a>() <span class="keyword">const</span>;
<a name="l00194"></a>00194         <span class="keywordtype">void</span> GetWaitObjects(<a class="code" href="class_wait_object_container.html" title="container of wait objects">WaitObjectContainer</a> &amp;container, <a class="code" href="class_call_stack.html">CallStack</a> <span class="keyword">const</span>&amp; callStack);
<a name="l00195"></a>00195 
<a name="l00196"></a>00196         <span class="keywordtype">size_t</span> <a class="code" href="class_buffered_transformation.html#ad396dcb42260f23125a35ec0e5d17d55" title="input multiple bytes for blocking or non-blocking processing">Put2</a>(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking);
<a name="l00197"></a>00197 
<a name="l00198"></a>00198         <span class="keywordtype">void</span> SetMaxBufferSize(<span class="keywordtype">size_t</span> maxBufferSize) {m_maxBufferSize = maxBufferSize; m_buffer.SetNodeSize(UnsignedMin(maxBufferSize, 16U*1024U+256U));}
<a name="l00199"></a><a class="code" href="class_network_sink.html#a2fe72dabc3ad9d77bbff0cbc2d73f2dc">00199</a>         <span class="keywordtype">void</span> <a class="code" href="class_network_sink.html#a2fe72dabc3ad9d77bbff0cbc2d73f2dc" title="set a bound which will cause sink to flush if exceeded by GetCurrentBufferSize()">SetAutoFlushBound</a>(<span class="keywordtype">size_t</span> bound) {m_autoFlushBound = bound;}
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         <span class="keywordtype">size_t</span> GetMaxBufferSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_maxBufferSize;}
<a name="l00202"></a>00202         <span class="keywordtype">size_t</span> GetCurrentBufferSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<span class="keywordtype">size_t</span>)m_buffer.CurrentSize();}
<a name="l00203"></a>00203 
<a name="l00204"></a>00204         <span class="keywordtype">void</span> ClearBuffer() { m_buffer.Clear(); }
<a name="l00205"></a>00205 
<a name="l00206"></a>00206         <span class="keywordtype">bool</span> EofPending()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_eofState &gt; EOF_NONE &amp;&amp; m_eofState &lt; EOF_DONE; }
<a name="l00207"></a>00207 <span class="comment"></span>
<a name="l00208"></a>00208 <span class="comment">        //! compute the current speed of this sink in bytes per second</span>
<a name="l00209"></a>00209 <span class="comment"></span>        <span class="keywordtype">float</span> <a class="code" href="class_nonblocking_sink_info.html#af886aa0d245f4068fa6cba194ec94188" title="compute the current speed of this sink in bytes per second">ComputeCurrentSpeed</a>();<span class="comment"></span>
<a name="l00210"></a>00210 <span class="comment">        //! get the maximum observed speed of this sink in bytes per second</span>
<a name="l00211"></a>00211 <span class="comment"></span>        <span class="keywordtype">float</span> <a class="code" href="class_nonblocking_sink_info.html#a8a548f66bcf4711c37bca79411e29703" title="get the maximum observed speed of this sink in bytes per second">GetMaxObservedSpeed</a>() <span class="keyword">const</span>;
<a name="l00212"></a>00212 
<a name="l00213"></a>00213 <span class="keyword">protected</span>:
<a name="l00214"></a>00214         lword DoFlush(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxTime, <span class="keywordtype">size_t</span> targetSize);
<a name="l00215"></a>00215 
<a name="l00216"></a>00216         <span class="keyword">virtual</span> <a class="code" href="class_network_sender.html" title="Network Sender.">NetworkSender</a> &amp; AccessSender() =0;
<a name="l00217"></a>00217         <span class="keyword">const</span> <a class="code" href="class_network_sender.html" title="Network Sender.">NetworkSender</a> &amp; GetSender()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">const_cast&lt;</span><a class="code" href="class_network_sink.html" title="Network Sink.">NetworkSink</a> *<span class="keyword">&gt;</span>(<span class="keyword">this</span>)-&gt;AccessSender();}
<a name="l00218"></a>00218 
<a name="l00219"></a>00219 <span class="keyword">private</span>:
<a name="l00220"></a>00220         <span class="keyword">enum</span> EofState { EOF_NONE, EOF_PENDING_SEND, EOF_PENDING_DELIVERY, EOF_DONE };
<a name="l00221"></a>00221 
<a name="l00222"></a>00222         <span class="keywordtype">size_t</span> m_maxBufferSize, m_autoFlushBound;
<a name="l00223"></a>00223         <span class="keywordtype">bool</span> m_needSendResult, m_wasBlocked;
<a name="l00224"></a>00224         EofState m_eofState;
<a name="l00225"></a>00225         <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> m_buffer;
<a name="l00226"></a>00226         <span class="keywordtype">size_t</span> m_skipBytes;
<a name="l00227"></a>00227         <a class="code" href="class_timer.html" title="high resolution timer">Timer</a> m_speedTimer;
<a name="l00228"></a>00228         <span class="keywordtype">float</span> m_byteCountSinceLastTimerReset, m_currentSpeed, m_maxObservedSpeed;
<a name="l00229"></a>00229 };
<a name="l00230"></a>00230 
<a name="l00231"></a>00231 NAMESPACE_END
<a name="l00232"></a>00232 
<a name="l00233"></a>00233 <span class="preprocessor">#endif  // #ifdef HIGHRES_TIMER_AVAILABLE</span>
<a name="l00234"></a>00234 <span class="preprocessor"></span>
<a name="l00235"></a>00235 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sun Oct 16 2011 for Crypto++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>