delphi - TIdTcpServer connection limiting -


i want restrict number of incoming connections tidtcpserver can take, rule need apply little complex, don't think maxconnections property work me.

i have application running n servers, each using different protocol on different port. need limit total number of clients across n servers. example, 16 servers, , 16 clients allowed, allow 1 client on each, or 16 on single server.

it's possible manipulate maxconnections dynamically fix (e.g. set them 0 when determine we're 'full', , 16 or whatever when we're not full, feels little tricksy.

is there kind of virtual isconnectionallowed method can override own logic, or suitable place in connection process can raise exception if determine limit has been exceeded?

create new component - tidtcpservercollection example - "owner" of server components.

in component, declare thread-safe property stores available - unused - connection count.

in server connect , disconnect logic, decrement / increment variable, , set maxconnections reflect new limit.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -