On Dec 1, 2003, at 12:18 PM, James Edward Gray II wrote: [..]

If you can get by with the line oriented reads and writes, by all means use them and save yourself a lot of pain. That's rare in networking though, in my experience.

If you really do need sysread(), you'll need to check
it with select() to see when data is available and buffer
your reads until you know you have an entire message.

one way simplistic way to try the sysread() approach would be go with something like

my $message;

        my $bytes=1;
        while ($bytes)
        {
                $bytes = sysread(SOCK,$buf,4096);
                $message .= $buf;
                # or try say
                # last if eof(SOCK);
        }

Assuming of course that one is just going
to read the socket dry, and the server side
will close it off so that the eof() event
will be 'hearable'.

The alternative of course is to go with some
sort of 'header/payload' approach, in which
the header will call out how many bytes are
to be read off the socket as 'payload'. Or
build out a 'non-line oriented' protocol
that offers a specific EOM ( end of message )
indicator, or ....

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to