nagalenoj has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I've used IO::Select package and can_read to do polling in my socket. Here is my question,
while(1) { my ( @read_sockets ) = $SELECT->can_read(5); if ( @read_sockets ) { foreach my $fh ( @read_sockets ) { my $data = <$fh>; print "Got data from server, $data"; $data =~ s/\n$//; } } }
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.
So, what is the better way to use can_read for multi line messages??
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: IO::Select - reading multiple lines
by zentara (Archbishop) on Jul 07, 2011 at 12:04 UTC | |
by Somni (Friar) on Jul 07, 2011 at 18:53 UTC | |
by nagalenoj (Friar) on Jul 14, 2011 at 13:23 UTC | |
by zentara (Archbishop) on Jul 14, 2011 at 19:20 UTC | |
by nagalenoj (Friar) on Jul 15, 2011 at 12:16 UTC | |
by zentara (Archbishop) on Jul 15, 2011 at 12:23 UTC |
Back to
Seekers of Perl Wisdom