networking - how do sockets not missing arriving data? -


a typical socket program example this:

while(1){    data = socket.recv()    //do work } 

since don't know when package arrive,it must block wait until data listening port,suppose if program start heavy work after received command side,during work , package arrived,but because @ moment doing work,you not listening port, might missed package ,no matter how fast handle work.

so how socket work handle data without lost?

the operating system has receive buffer holds packets have been received network not yet recv()ed application. if buffer fills packets lost. don't have in recv() call when packets arrive, though should make sure call enough keep buffer overflowing.


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -