<?xml version="1.0" encoding="windows-1252"?>
<node id="913153" title="IO::Select - reading multiple lines" created="2011-07-07 05:03:08" updated="2011-07-07 05:03:08">
<type id="115">
perlquestion</type>
<author id="711414">
nagalenoj</author>
<data>
<field name="doctext">
Hi,
&lt;p&gt; I've used IO::Select package and can_read to do polling in my socket. Here is my question,&lt;/p&gt;

&lt;code&gt;
while(1)  {
  my ( @read_sockets ) = $SELECT-&gt;can_read(5);
  if ( @read_sockets )  {
    foreach my $fh ( @read_sockets ) {
      my $data = &lt;$fh&gt;;
      print "Got data from server, $data";
      $data =~ s/\n$//;
    }
  }
}
&lt;/code&gt;

&lt;p&gt;When server sends me multiple line messages. can_read returns the socket handle and I read the first line of it(as per the above code). I thought if I do can_read again, I'll get the socket handle returned as some data is not yet read. But, can_read is blocking and not returning the socket handle.&lt;/p&gt;
&lt;p&gt;
So, what is the better way to use can_read for multi line messages??&lt;/p&gt;
&lt;/p&gt;</field>
</data>
</node>
