Here is some code quoted from Douglas.E.Comer’s < Computer Networks and Internets > 4th edition. This program will send back any data it received.
...
while((len = recv(conn, buff, BUFFERSIZE,0)) >0) // receive data
send(conn, buff, len, 0); // send it back
...
I am wondering, what if some data arrived when the code is executing in send(..) function, will it miss that data? Because the recv() function is not being executed. If no data is missed, where is the data kept? And by whom?
Thanks…
Incoming data is buffered by the system until the next time the
recv()function is called. This data that hasn’t been read yet is stored in buffers inside the operating system and not inside your application. You will not “miss” incoming data using a loop like this.