Nuno Carvalho wrote:

> > >  How can I limit a certain number of connections to a port !?
>    ....
> > >        int listen(int s, int backlog);
> > >
> > >  What should I do for that !?
> >
> > If you wish to limit the number of connections, you have to stop
> > accept()ing new connections once you have reached the limit.
> 
>  Shouldn't listen do that !? Should I take care about number connections,
> rigth !?

The `backlog' argument to listen() determines how many connections it
will queue pending an accept() call. Every time that you call
accept(), you remove a pending connection from the queue.

>  Could you help me on limit connections !?

1. Whenever you accept() a new connection, increment the counter.

2. Whenever a child process dies, you need to decrement the counter.
This is the part which you are not doing.

3. When the counter reaches the limit, you need to stop calling
accept() until the counter is decremented.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to