What value of backlog should I use?

mathieug picture mathieug · Apr 4, 2012 · Viewed 13.6k times · Source

I read the man 2 listen.

I don't understand what is the backlog value, it says

The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow

Right, how can I define what is the best value?

Thanks

Answer

user149341 picture user149341 · Apr 4, 2012

Basically, what the listen() backlog affects is how many incoming connections can queue up if your application isn't accept()ing connections as soon as they come in. It's not particularly important to most applications. The maximum value used by most systems is 128, and passing that is generally safe.