As I understand, backlog determines the size of the connection queue. Any extra requests greater this size at that time will be dropped off(is this statment right??).
Now I have very simple program server.c
socket()
bind()
listen(..., 5)
while(1)
{
accept()
read()
write()
sleep(3)
close()
}
Now, I start 8 clients at a time to connect to this server. Surprisingly, the server serves all the 8 clients but instead it should queue only 5 clients & remaining 3 clients requests should be refused. Another interesting point is even if I put this backlog value as 0, the result is still same. Then I tried commenting listen() call, with this all 8 clients connections get refused.
Can somebody provide any inputs on this.
read
,write
andclose
in a concurrent environment. In your code, when the next connection isaccept
ed it seems the previous one has already been closed. Put the code in a thread and make sure each connection last sufficient long ensuring the situation 8 clients requesting your server simultaneously really occur. – Easley