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?
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?
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).
Thanks :lol: