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
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.
listen(sockfd, 5)
, should I test in my accept()
(in my infinite loop) if current_nb_client < 5
in order to send a error message to my client or can I trust backlog and handle this in client-side - mathieug 2012-04-03 23:57
accept()
each and they disappear from the queue - mathieug 2012-04-04 01:04
It's a fight between clients trying to connect. pushing accept requests onto the queue, and the accept thread/s sucking them off. Usually, the threads win. I usually set at 32, but it's not usually an important parameter.
listen(sockfd, 5)
, should I test in my accept()
(in my infinite loop) if current_nb_client < 5
in order to send a error message to my client or can I trust backlog and handle this in client-side - mathieug 2012-04-03 23:57