There was such a little question . When a process registers with the socket ,, Suppose the socket is not called recv Function accept package . Can I receive packets ? Or so to speak , Suppose my program registers a socket to accept packets , However, it takes a long time to process every packet received , And on the way to processing packets recv Function to make an unused . Let's assume that a packet arrives on the way to reprocessing the packet , Will my program miss these packets ( When that packet arrived, the program was processing other packets , Instead of calling recv function )?
    The answer is no .

Actually linux A cache is set up for each socket in , When the packet belonging to the socket arrives , Only if the socket has been registered , Whether or not you called recv function , Packets are stored in the socket cache ( It's actually a skb Structure linked list ), Just don't fill the cache , You can call at any time recv Function to fetch packets from the cache .

I found through experiments that , It takes a very long time for packets to park in the cache , My personal guess is that until this socket is closed .

    So far as caching is concerned , Studied tcpip I'm sure you can think of it tcp Flow control of sliding window in . you 're right , The window size value there is actually the current remaining cache size value of your socket . By default, the initial cache size of the socket is 8192 byte , Of course , This can also be adjusted with socket options .

therefore , Only one socket has to be registered , When the packet arrives, it will be processed by the protocol stack of the kernel first , At this point, even if your program doesn't handle packets , Packages are also stored in the kernel cache .

Copyright notice : This article is an original blog article , Blog , Without consent , Shall not be reproduced .

linuxsocket signal communication recv More articles on caching mechanism

  1. First time to know nginx Reverse proxy and caching mechanism

    The requirements map of the implementation :   Environmental Science : nginx Caching and reverse proxy servers :192.168.0.224 The actual data storage machine :192.168.0.37 One . Implement reverse proxy 1. install nginx, Both servers need to be installed 1) install ...

  2. linux The cache mechanism under the buffer、cache、swap - Operation and maintenance summary ["Cannot allocate memory" problem ]

    One . Introduction to caching mechanism stay Linux In the system , To improve file system performance , The kernel uses part of the physical memory to allocate buffers , For caching system operations and data files , When the kernel receives a read-write request , The kernel first goes to the cache to find if there is any requested data , Go straight back if you have , If ...

  3. linux The cache mechanism under the buffer、cache、swap

    One . Introduction to caching mechanism stay Linux In the system , To improve file system performance , The kernel uses part of the physical memory to allocate buffers , For caching system operations and data files , When the kernel receives a read-write request , The kernel first goes to the cache to find if there is any requested data , Go straight back if you have , If ...

  4. Starting from scratch , Build a blog system MVC5+EF6 Building framework (3), add to Nlog journal 、 Caching mechanisms (MemoryCache、RedisCache)、 Create a controller parent BaseController

    One . Review the system progress and the summary of this chapter At present, the blog system has created a database . And dependency injection Autofac Integrate , Next is logging and caching Integration , The log here uses Nlog, In fact, there are other logging frameworks, such as log4, There are many introductions in these blog parks , this ...

  5. C# Infinite classification tree - establish - Sort - Read use Asp.Net Core+EF The second way to realize it : Join the caching mechanism

    In the last article, I implemented the management menu recursively , In the last section, I also mentioned to consider caching , It's a study .Net Core Cache mechanism . About .Net Core The cache of , There are three kinds of official implementations : 1.In Memory Cachi ...

  6. 【 tencent Bugly Dry cargo sharing 】Android ListView And RecyclerView Comparative analysis -- Caching mechanisms

    This article is from Tencent bugly Developer community , Without the consent of the author , Do not reprint , Original address :http://dev.qq.com/topic/5811d3e3ab10c62013697408 author : Huang Ningyuan One , background Recy ...

  7. IOS Cache mechanism details

    All the information comes from the Internet , When reprinting, please make sure to indicate the article in the form of hyperlink Original source . Author information and this statement . Otherwise, the legal liability will be investigated . Man seven seven seven :http://www.cnblogs.com/qiqibo/ Why do we have caching Applications need to be ...

  8. analyse OkHttp Caching mechanisms

    Now it's on the market App All of them need network operation , Most of the developers of these applications choose to use them in combination  OkHttp  and  Retrofit  To complete the network operation .okHttp One of the most acclaimed features is its caching mechanism , And I'll be in this article ...

  9. HTTP The caching mechanism of the browser in the request

    Abstract : stay Web Development process , We may often encounter browser caching problems . The author of this article explains the mechanism of browser caching in detail , Help readers understand the cache of browser in a deeper level . technological process When a resource is first accessed ,HTTP Head down (Reques ...

Random recommendation

  1. Mysql A summary of the basic sentences

    1--------------- Create a table ------------------------------------ drop table if exists Table name create   table Table name ( ...

  2. HDU 1698 & UESTC 1228 Just a hook

    It's a water problem in the line tree , Lazy operation must be used , Otherwise it will time out . Or you can start without counting and , Only update nodes , Finally, calculate the color of the whole line segment and . 1. Lazy operation /* 908ms 3448KB in HDU OJ*/ #inclu ...

  3. jQuery The radio of , check , The drop-down

    The radio obtain ($('input:first').attr('vlaue')); Choose ($('input:checked').val()); Property value setting $().val( Property value )$('input:fi ...

  4. ( turn ) use eclipse Create a j2ee Of web After the project , left side projects How the items in the window are not displayed webRoot Folder , except src Folder , Nothing else is shown

    Top right of the left directory window , There's a downward arrow , Point to the inside filters, Take out all the hooks and have a look

  5. VS 2012 Plug in uninstall ( Remove the plug-ins you installed )

    to VS A plug-in is installed , I feel uncomfortable after loading , So I want to unload ,[ Tools ]--> [ Expansion and update ]-->[ Find the plug-in you want to uninstall and click it to disable or uninstall it ]

  6. web In the browser javascript 1

    Html The document embedded client has 4 Ways of planting . 1. inline . Put in <script> and </script> Between label pairs . 2. Put in <script> Labeled src Property in the external file specified by the ...

  7. [51nod1197] The number of strings V2

    use N Different characters ( Number 1 - N), Make a string , There are the following requirements : (1) For No i The characters of , If 2 * i > n, Then the character can be used as the ending character . If it's not the ending character but the middle character , Then the character can be followed by ...

  8. LOJ#2553 Violent writing and hanging

    The question : Given two trees T1,T2, seek d1[x] + d1[y] - d1[lca1(x, y)] - d2[lca2(x, y)] The maximum of . Explain : Think about turning this tumor into something . Finding it is T1 in x,y The way to the root ...

  9. senior Bash Scripting guide 《Advanced Bash-Scripting Guide》 in Chinese

    <Advanced Bash-Scripting Guide> in Chinese < senior Bash Scripting guide >Revision 10 Chinese version Read links online :http://ww ...

  10. ( file )Shader.Find ( At compile time , Only those in use shader Or position in &quot;Resources&quot; In the folder shader)

    Shader.Find lookup static function Find (name : string) : Shader Description describe Finds a shader with the g ...