Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: IO::Socket hanging

by etcshadow (Priest)
on Nov 22, 2004 at 06:57 UTC ( [id://409507]=note: print w/replies, xml ) Need Help??


in reply to IO::Socket hanging

The basic issue is that <$rh> does a buffered read from the socket, meaning that it won't return from the read call until $/ (defaults to "\n") is encountered on the channel. IO::Select::can_read just means that there is data on the channel, it does not necessarily mean that there is a full record (defined as: a chunk terminated with an occurence of $/) waiting on the channel.

The proper solution is either to change (locally) the value of $/ to whatever makes sense for the records you are sending accross the channel... if you are willing to rely on the fact that only complete records get sent (otherwise you can gum up the process with blocking incomplete buffered reads), OR to change it from a buffering read to a non-buffering read (the better but more involved solution). For that, take a look at perldoc -f sysread for more details.

------------ :Wq Not an editor command: Wq

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://409507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found