Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Mar : Re: How to limit number of concurrent clients in TServerSocket?
| Subject: | Re: How to limit number of concurrent clients in TServerSocket? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Mon, 24 Mar 2008 10:12:55 |
"Bo Berglund" <bo.berglund@telia.com> wrote in message
news:o4dcu3dmejk5n3du85v3t14h8hq00lic15@4ax.com...
> But there seems to be no property on TServerSocket that can be used to
> limit the number of connections, so what is the best way to do it?
TServerSocket is not really designed for that. The best you can do is
Close() the new connection in the OnClientConnect event hander if a previous
connection already exists.
Otherwise, use a different component. In Indy, for instance, the
TIdTCPServer component has a MaxConnections property that you could set to
1. Or you can use its TIdSimpleServer component, which is specifically
designed to accept only 1 client at a time instead.
> I cannot switch it to Indy because this would be way too much work....
Then you will have to Close() new connections, as described above.
> I assume that it should be possible to somehow reject a connection if
> the server already has an active connection running.
Reject, no. Disconnect, yes.
> Or can one stop listening on the remote port while a client is connected?
Not without crasing the server, no.
Gambit