Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: Read a line with max length ?

by Elian (Parson)
on Feb 27, 2003 at 23:15 UTC ( #239289=note: print w/replies, xml ) Need Help??

in reply to Re: Read a line with max length ?
in thread Read a line with max length ?

You should read more than one byte at a time. It's not particularly dangerous, and works just fine. A buffer size of 1500 is good, since it tends to match the maximum TCP/IP frame size. Sockets have timeouts, so worst case your program will pause waiting for the remote end, but that'll happen for a one-byte read just as often, so it's not a problem that you're avoiding.

Note that a read on a socket for more data than is available won't stall. If you issue a read for 1500 bytes but there's only 100 available, you'll get 100 back, barring really bizarre OS bugsfeatures.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://239289]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2023-10-04 23:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found