Question about listening and backlog for sockets

前端 未结 3 1882
情书的邮戳
情书的邮戳 2020-12-09 05:57

I am writing an application in C# that needs to handle incoming connections and I\'ve never done server side programming before. This leads me to these following questions:<

3条回答
  •  独厮守ぢ
    2020-12-09 06:28

    What the backlog does is provide a queue with clients that are trying to connect to the server, but which you haven't processed yet.

    This concerns the time between when the client actually connects to the server and the time you Accept or EndAccept the client.

    If accepting a client takes a long time, it is possible that the backlog becomes full and new client connections will be rejected until you had time to process clients from the queue.

    Concerning your questions:

    1. I don't have information on that. If the default number does not pose any problems (no rejected client connections) leave it at its default. If you see many errors when new clients want to connect, increase the number. However, this will probably be because you take too much time accepting a new client. You should solve that issue before increasing the backlog;

    2. No, this is handled by the system. The normal mechanism of accepting clients takes care of this;

    3. See my earlier explanation.

提交回复
热议问题