diff options
Diffstat (limited to 'html/091socket.cc.html')
-rw-r--r-- | html/091socket.cc.html | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/html/091socket.cc.html b/html/091socket.cc.html index a3bd7316..a81f4c79 100644 --- a/html/091socket.cc.html +++ b/html/091socket.cc.html @@ -251,7 +251,6 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> _READ_FROM_SOCKET: <span class="Delimiter">{</span> - cerr << <span class="Constant">"$read-from-socket</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> x = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> socket_t* socket = <span class="Normal">reinterpret_cast</span><socket_t*><span class="Delimiter">(</span>x<span class="Delimiter">);</span> <span class="Comment">// 1. we'd like to simply read() from the socket</span> @@ -261,22 +260,19 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// 3. but poll() will block on EOF, so only use poll() on the very first</span> <span class="Comment">// $read-from-socket on a socket</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!socket<span class="Delimiter">-></span>polled<span class="Delimiter">)</span> <span class="Delimiter">{</span> + socket<span class="Delimiter">-></span>polled = <span class="Constant">true</span><span class="Delimiter">;</span> pollfd p<span class="Delimiter">;</span> bzero<span class="Delimiter">(</span>&p<span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span>p<span class="Delimiter">));</span> p<span class="Delimiter">.</span>fd = socket<span class="Delimiter">-></span>fd<span class="Delimiter">;</span> p<span class="Delimiter">.</span>events = POLLIN | POLLHUP<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>poll<span class="Delimiter">(</span>&p<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">num pollfds</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">timeout</span><span class="Comment">*/</span><span class="Constant">100</span><span class="Comment">/*</span><span class="Comment">ms</span><span class="Comment">*/</span><span class="Delimiter">)</span> <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>poll<span class="Delimiter">(</span>&p<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">num pollfds</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">no timeout</span><span class="Comment">*/</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"error in $read-from-socket</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - cerr << <span class="Constant">"poll output: "</span> << p<span class="Delimiter">.</span>revents << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> - cerr << <span class="Constant">"setting socket->polled</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - socket<span class="Delimiter">-></span>polled = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - cerr << <span class="Constant">"$read-from-socket "</span> << x << <span class="Constant">" continuing</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> <span class="Normal">int</span> bytes = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Normal">char</span>* contents = <span class="Normal">new</span> <span class="Normal">char</span>[bytes]<span class="Delimiter">;</span> bzero<span class="Delimiter">(</span>contents<span class="Delimiter">,</span> bytes<span class="Delimiter">);</span> |