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

Re: IO::Socket hanging

by etcshadow (Priest)
on Nov 22, 2004 at 06:57 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2019-10-14 06:29 GMT
Find Nodes?
    Voting Booth?