I'm creating a program similar to a telnet server.
I have to read from a socket with a SOCK_STREAM connection
When I read a line using recv, what is the best buffer size for reading?
Should I read only a char each time or should I read a MAX_BUFF chars each time?
If the user enter 10 chars and I use recv with a 20 bytes long buffer, does the recv block and waits for the other 10 bytes?
Posted on 2005-09-06 15:48:31 by greenant
You should read "MAX_BUFF" chars at a time, BUT always check the returned amount of bytes - you won't always get a full buffer. You should also be very very VERY careful about not overflowing your buffer, be careful if you're reading strings (zero-termination, copying to buffers that are too small, et cetera).
Posted on 2005-09-06 16:20:59 by f0dder
Thanks  :lol:
Posted on 2005-09-07 03:36:08 by greenant