in reply to Re^5: Waiting for input, without sleep
in thread Waiting for input, without sleep

So the message I get back then is still 0? Should I still be using sysread?

Replies are listed 'Best First'.
Re^7: Waiting for input, without sleep
by jrsimmon (Hermit) on Jun 30, 2009 at 16:45 UTC
    Yes, you use peek() to know whether or not it is time to read(). The difference between peek() and read() is that read() removes from the socket the data that was read, where peek() simply reports what is there without altering it. This allows you to peek() repeatedly until the full contents of a message are available, at which time you read() to retrieve the message and remove it from the socket buffer.

    Also, I think your syntax for peek() should look more like your syntax for sysread(...) (I'm not overly familiar with sockets in perl and you seem capable of tracking the details down, so I'll leave that to you.) I'd prefer the cpan module be more explicit about the arguments and return value, but evidently that's just me.
      Yeah, I agree with you there...

      Thanks a million for all your help. I seem to be in the right direction now. I'll leave a post back with the final result when I have it finished.

      Have a wonderful day! :D