<?xml version="1.0" encoding="windows-1252"?>
<node id="21058" title="RE: Reading from more than one socket at once" created="2000-07-04 21:09:56" updated="2005-08-15 10:48:22">
<type id="11">
note</type>
<author id="20906">
splinky</author>
<data>
<field name="doctext">
Overall, good stuff.  But I think you better doublecheck 
that "Perl will read a few bytes ahead to improve 
performance" claim.  I don't recall coming across that
anywhere else before.  In particular, I've used 
&lt;code&gt;print&lt;/code&gt; and &lt;code&gt;&lt;&gt;&lt;/code&gt; with sockets before
with no problems.  The key is to not mix them with 
&lt;code&gt;sysread&lt;/code&gt; and &lt;code&gt;syswrite&lt;/code&gt;.
&lt;p&gt;
Also, I think IO::Socket and IO::Select deserve more space.
After becoming comfortable with them, I far prefer them
over the raw Perl stuff, which looks more like C than Perl.
There's a good example of both IO::Socket and IO::Select
at the end of perldoc IO::Select.  Of course, it should be 
noted that the major limitation of IO::Select is that it
doesn't allow you to wait for reading,
writing, and exceptions simultaneously.  You have to pick 
one.  But, for the example you show, that's not a limitation.
&lt;p&gt;
Finally, one minor thing:  "get all the data it wants before 
continue" should be "...continuing".
&lt;p&gt;
But, overall, pretty good stuff.  Have a Scooby snack on me.
&lt;p&gt;
&lt;a href="/index.pl?node=splinky&amp;lastnode_id=1072"&gt;*Woof*&lt;/a&gt;</field>
<field name="root_node">
21054</field>
<field name="parent_node">
21054</field>
</data>
</node>
