in reply to socket reading...

Your problem could probably be fixed by placing the socket in non-blocking mode. When in non-blocking mode it is gaurenteed that your process will not block from operations on the socket. However, this means that you should check the return values of all your reads (and writes, maybe) in case they return an error ( for when blocking would have occured, EAGAIN ("Resource temporarily unavailable" (but locale can change that message)); the Errno module will be helpful.) You can turn blocking off with:

$sock->blocking(0);

Note that IO::Select provides an alternate select interface that you aren't using. You do not need to use a module to use the built-in select interface.

Note that when sysread returns 0 that means EOF.

Replies are listed 'Best First'.
Re: Re: socket reading...
by jdv79 (Sexton) on Jul 28, 2001 at 03:56 UTC
    I tried using your $sock->blocking(0); and it produced this: Can't locate auto/IO/Socket/INET/blocking.al in @INC (@INC contains: /usr/lib5 I am not familiar with .al
    Thanks alot for your help!
      This appears to indicate that your installation of the IO::Socket::INET module (which comes with perl since perl version 5.004) is somehow curropted. It appears to indicate that AutoLoader was used for IO::Socket::INET, something which oddly I don't find evidence of in versions of perl I have access to (5.005_02, 5.6.0, 5.7.1@11471). It also seems to indicate that a file that was supposed to have been created by AutoSplit during installation cannot be found.

        IO::Socket::INET "isa" IO::Socket "isa" IO::Handle "isa" Exporter so if any of those have a AUTOLOAD, then IO::Socket::INET does. One of the many ugly pitfalls of using inheritance in Perl.

        Another ugly thing is that the default AUTOLOAD that often gets used gives this silly error about not finding a *.al file when the real problem is that the module user has mistyped the method name. There is no blocking.al file because there is no "blocking" method for that module. That error message is hugely misleading and I go out of my way to avoid it in the modules I write.

        blocking() is supposed to be an IO::Handle method. I suspect the problem is that this wasn't present in whatever version of Perl is being used. The problem could probably be solved by upgrading Perl.

                - tye (but my friends call me "Tye")