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

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -