[SOLVED] Listening socket backlog size. I can not understand the wording of a manpage – Stack Overflow

Issue

This Content is from Stack Overflow. Question asked by user14063792468

My man pages for kqueue give me the following:

 EVFILT_READ         Takes a descriptor as the identifier, and returns
                     whenever there is data available to read.  The
                     behavior of the filter is slightly different
                     depending on the descriptor type.

                     Sockets
                         Sockets which have previously been passed to
                         listen() return when there is an incoming
                         connection pending.  data contains the size of
                         the listen backlog.

The question follows, is above backlog value equals the number of total backlog size, or, the value equals the actual backlog size, as the event returns to a user?



Solution

It equals to the actual listen queue size. Yes, the actual connection(accept) may not succeed. But, I do not think that the listen queue size will change while accept calls being made. I’m not so competent in reading source code, but I can do a simple logic:

1. There is a list of connections waiting to be accepted.
2. The connection may either succeed or fail.
 3. If the connection succeeds, it does not change a queue size.
 4. If the connection fails, the `accept` function returns the reason.
5. From above, the status of a connection will not change actual
   listen backlog. 
   You also can made this logic from error codes of `accept` function. If the system removes a connection, the accept returns an error.


This Question was asked in StackOverflow by user14063792468 and Answered by user14063792468 It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?