serg_remote has asked for the wisdom of the Perl Monks concerning the following question:

hi all,
I had problems with timeouts when I used "print $sock" instead of "$sock->send". some semi-down hosts made large delays more than 5 minutes. neither eval/alarm nor 'Timeout' socket parameter didn't work.
I never could think that there is a difference between print and send. send instead of print works fine. but in many places(FAQs, official perl docs, modules) people use and offer others to use print.
how do u think can it be fixed at least in documentation?

thank you

Replies are listed 'Best First'.
Re: print $socket $message
by monarch (Priest) on Nov 23, 2005 at 10:53 UTC
    I presume you're talking about IO::Socket::INET?

    I've found that the Timeout parameter, when set in the new() method, has no effect if the remote device is not responding.. in which case an alarm() within an eval { } does actually help.

    As for attempting to send to a down-host, I have little experience with this, other than using IO::Select and syswrite() to make sending non-blocking, and implementing application-level timeouts to protect against a host going down in the middle of a process.

      yep, IO::Socket::INET or sockets made by builtin functions- they're the same.
      you're right, you need to use eval/alarm block anyway but if you use print instead of send it doesn't work.
      and I found no points in manuals about it. I don't know is it a bug or just undocumented feature- in both cases newbies might have stupid problems :(