What is the best solution to knowing when a server or client has sent the final piece of data across a socket?
For example, let say a client sends 100k of data to a server running OVERLAPPED I/O. The I/O model updates the server and tells it there is 50k data ready for to be received. The server calls WSARecv(). Meanwhile the server has not idea the true size of the data. It just knows there is 50k worth of the data. Now OVERLAPPED I/O updates the server the second time with 50k data, which is the last piece of data.
Based on the example scenario, how does the server know when to stop calling WSARecv() because it has processed all data? This is a general question and does not pertain to data. Is it true that web servers sends the final piece of data with something ike this at the end?