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. | [reply] |
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.
| [reply] [d/l] |