Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Answer: What is the easy way to check if the socket has data to read, before do a read()

by perlknight (Pilgrim)
on Jul 24, 2002 at 14:21 UTC ( #184851=categorized answer: print w/replies, xml ) Need Help??

Q&A > network programming > What is the easy way to check if the socket has data to read, before do a read() - Answer contributed by perlknight

Use IO::Select, pass the socket handle to it and use can_read method to detemine if the handle is ready, here's snippet from perldoc:
use IO::Socket; use IO::Select; $lsn = new IO::Socket::INET(Listen => 1, LocalPort => 8080); $sel = new IO::Select( $lsn ); while(@ready = $sel->can_read) { ... }

  • Comment on Answer: What is the easy way to check if the socket has data to read, before do a read()
  • Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Discipulus]: marioroy did you know zentara is back to themonastery? he was used to be one of the best parallel programming monks
[makita]: sign_types parameter in XML::Compile::WSS ::Signature Does have anybody experience how to use it?
[makita]: Need to sign more elements but all types I put in array are ignored. And is always signed only the body
[Discipulus]: no makita sorry. i see in the synopsis of the module: "WARNING: Only limited real-life experience" might be better compose a SOPW with some code example and data

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-03-23 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.