in reply to Re: IO::Handle read error description?
in thread IO::Handle read error description?

hm. for this socket should be in non-blocking mode, right ?
  • Comment on Re^2: IO::Handle read error description?

Replies are listed 'Best First'.
Re^3: IO::Handle read error description?
by ikegami (Patriarch) on Apr 28, 2010 at 17:56 UTC

    No. The whole point of using select is to let us know when reading from the socket won't block and when writing to the socket won't block.

    Unfortunately, it doesn't tell us how much we can write to it without blocking. We only know that we can write one byte without blocking. Maybe non-blocking sockets would help in the writing half. Ideally, there would be a system call that tells us how much we can write without writing. I don't know if there is one.

      I was thinking sysread(... 4096 ... will block until read all 4096 bytes...
        It will return whatever bytes are available.
        $ perl -e'$|=1; print "a"; print "b"; sleep 1; print "c"' | \ perl -le'print "[$buf]" while sysread(STDIN, $buf="", 4096);' [ab] [c]