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

Its just a string that comes back in, however there is one section of information I get back that is of variable length. This is why I have it set to the high 4000.

Replies are listed 'Best First'.
Re^3: Waiting for input, without sleep
by ikegami (Patriarch) on Jun 30, 2009 at 16:02 UTC
    That doesn't answer anything. Strings are objects consisting of a length and a series of characters. How do you encode these (individually if applicable, and as a whole)?
      I'm not sure what to say really. I open a socket and get a message back from the server. My initial script above works just fine however, I was just thinking there might be a better way to get the message back.

      The server is sending the message back to me in HEX, but as you can guess by my function name, i'm displaying the hex version and converting it to a "string" or human readable stuff.

        My initial script above works just fine

        More like "My initial script happened to work when I ran it". I wouldn't call that "fine". It's incredibly fragile since you have no way of knowing if you're received all incoming data or not.

        One usually reads a constant number of bytes, a previously transmitted number of bytes or until a sentinel is encountered. Reading for a predetermined amount of time is a new one for me.

        Even if the whole string has arrived within the four seconds, a single sysread is not guaranteed to get all by bytes.