I have a few questions about the socket library in C. Here is a snippet of code I'll refer to in my questions.
char recv_buffer[3000];
recv(socket, recv_buffer, 3000, 0);
- How do I decide how big to make recv_buffer? I'm using 3000, but it's arbitrary.
- what happens if
recv()
receives a packet bigger than my buffer? - how can I know if I have received the entire message without calling recv again and have it wait forever when there is nothing to be received?
- is there a way I can make a buffer not have a fixed amount of space, so that I can keep adding to it without fear of running out of space? maybe using
strcat
to concatenate the latestrecv()
response to the buffer?
I know it's a lot of questions in one, but I would greatly appreciate any responses.