Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Mar : Re: How to limit number of concurrent clients in TServerSocket?

www.cryer.info
Managed Newsgroup Archive

Re: How to limit number of concurrent clients in TServerSocket?

Subject:Re: How to limit number of concurrent clients in TServerSocket?
Posted by:"Bo Berglund" (bo.berglu..@telia.com)
Date:Fri, 28 Mar 2008 00:36:54

On Thu, 27 Mar 2008 16:22:39 -0700, "Remy Lebeau \(TeamB\)"
<no.spam@no.spam.com> wrote:


>> If the answer is yes then maybe I must add a timer or similar
>> on the server application that can be used to check if there
>> has been any activity from the client within a set time.
>
>That is a good idea to implement in general anyway.  Even if the network
>does not go down, the client may still go silent on its end.  The connection
>will still be valid, but no data comes from it.

I will also detect a user that left his client connected while getting
out to lunch...

>
>> If GetTickCount - FActivityTime > MaxIdleTime then
>
>You do know that using tick counts like that will not work correctly after
>49.7 days, right?  You would be better off using a TDateTime instead.

Yes, I do. I always put in "roll-over" detection when I deal with
GetTickCount. We had a hit of this once a long time ago (like 10 years
or so) when an automation system deployed to a customer suddenly went
lame because a timeout set for a short time happened to hit the count
rollover and the result was that the timeout switched to 1.5
months....
Since then we look out for that. :-)
The code above was simplified for clarity.
But of course for these non-activity detctions TDateTime is better.

>
>>  What do I do here? I want to disconnect the client,
>> but I don't have the handle to the socket
>
>Yes, you do - TServerSocket.Socket.Connections[0]
Is there a Socket.Connections.Count property too?
So it is possible to enumerate the sockets?

I must say that the BDS2006 help system is really bad when dealing
with components like tehse. The one in Delphi7 was much better...

>
>> so Socket.Close won't work.
>
>Yes, it will.

Great, I'll use that then.


/BoB

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive