Click to See Complete Forum and Search --> : Problem with listen()


vni
July 25th, 2007, 08:06 AM
Hi all,
The purpose of listen() is to queue up the waiting clients to request to server and to restrict the number of clients,with which server can respond.
But listen is unable to restrict.it is accepting connections to more num of clients than specified.
Can anyone help me in knowingthe exact purpose and working of listen()?
And how to erstrict the number of clientsusing listen().

for ex:
llisten(sock,5);
Then server should be able to handle only 5 clients,if 6th client requests for connection,it shud be blocked.

Please help me.

MikeAThon
July 25th, 2007, 09:51 PM
for ex:
llisten(sock,5);
Then server should be able to handle only 5 clients,if 6th client requests for connection,it shud be blocked.
That's not the way listen() works. The parameter "5" simply specifies the maximum number of pending requests for connection. If there are 5 requests pending for connection, then if a sixth request comes in, it will turned away without adding it to the queue of pending requests (I think a FIN is sent for the sixth request).

But that does not limit the number of actual connections. It only limits the number of unconnected and pending requests to establish a new connection.

If you want to limit the number of concurrent connections, you will need to code that explicitly.

MIke

vni
July 26th, 2007, 03:35 AM
Thanks for the response.i got that.