[erlang-questions] how to limit number of connections to gen_tcp?

Jarrod Roberson <>
Wed May 27 01:28:24 CEST 2009

On Tue, May 26, 2009 at 5:37 PM, Essien Essien <> wrote:
> Hi Jarrod,
> Well, you are using synchronous accepts so, the only thing avaiable
> for you to do, is to keep a secondary "watchdog" counter loop. So when
> you recieve a new connection, you attempt to "register" it with the
> counter_loop, if it returns 'ok' to you, you go ahead, if it returns,
> 'overloaded' to you, you notify the client and close the connection.
> When a successfull connection eventually closes {tcp_close, ....}, you
> "deregister" the connection. An example _untested_ implementation is
> below. Hope that helps out a bit.

thanks this is more along the lines of what I was thinking it might
should look like.
I appreciate the help.

More information about the erlang-questions mailing list