Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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
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 browsing the Monastery: (4)
As of 2020-09-28 05:59 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (143 votes). Check out past polls.