📄 network_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: network.h Source File</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.5.2 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul></div><div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul></div><h1>network.h</h1><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 "config.h"</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 "filters.h"</span><a name="l00009"></a>00009 <span class="preprocessor">#include "hrtimer.h"</span><a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="preprocessor">#include <deque></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><a class="code" href="class_limited_bandwidth.html#68e356f18bc679289c9c44bbfe8e2de5">00018</a> LimitedBandwidth(lword maxBytesPerSecond = 0)<a name="l00019"></a>00019 : m_maxBytesPerSecond(maxBytesPerSecond), m_timer(<a class="code" href="class_timer.html" title="high resolution timer">Timer</a>::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><a class="code" href="class_limited_bandwidth.html#6bd1d7ab2fd038e150e058a30700b989">00023</a> 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><a class="code" href="class_limited_bandwidth.html#f2b5be51a91d335f7ced2270e0f871ce">00026</a> <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#1f5898c4e376b0d205fd784eaf5dec56">00038</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetMaxWaitObjectCount()<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> &container, <span class="keyword">const</span> <a class="code" href="class_call_stack.html">CallStack</a> &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<std::pair<double, lword> > 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><Source>, <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><a class="code" href="class_nonblocking_source.html#99c292bc821fe4235f8ca178401005c1">00058</a> <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(false) , m_doPumpBlocked(false), m_blockedBySpeedLimit(false) {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 &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#5dc7a255dd813433eeee3152544c2f1d" 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">'\n'</span>);<a name="l00067"></a>00067
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -