In terms of Winsock,
if the client sometimes needs to send 100 bytes and sometimes 1000 bytes for example, how is the server supposed to know before-hand the buffer size for the incoming send() from the client of 100 or 1000 bytes that i would need in recv() on the server?
Should i just set them both to a limit that i know for certain it won't reach, say 2048:
Client:
send(socket, cstr, 2048);
Server:
recv(socket, recvbuf, 2048);
Or should i do like the Winsock example and save packet space by when i send() by capping the buffer size at the c-string's size:
Client:
send(socket, cstr, strlen(cstr));
Server:
recv(socket, recvbuf, 2048);
Questions:
How do i determine the buffer size to use?
Should the send()'s buffer size always be capped at the length of data im sending(strlen(ctr)), or should it just be 2048 for example across the whole program?
Am i wasteing 2000+ bytes worth of packets if i do something like this
send(socket, "Username=Jimmy".c_str(), 2048);//not proper syntax i know
?