Indy: closing a connection on servers when all connectiosn closed, and timeouts

     Hopefully two not too hard questions. I have the latest stable version of Indy. I am probably just looking at the wrong properties.

1) how do I set timeouts on servers, so that if there is no data flowing, the connection is closed after x amount of time.
2) How do I test to see if there are any live connections to the servers, and if there are not, then stop the server.

ftpserver.Threads.LockList.Count = 0
appears to work well the first time I  check it, but then I set up a timer, then inside the timer I call

if ftps then begin
    if  and (ftpserver.Threads.LockList.Count = 0) then begin //the program dies here
      ftpserver.Active := false;
        ftps := false;
      end else good := false;
    good := false;

I have an antifreeze component on the form, and the problem happens both when I run from within the IDE and externally.

when the program dies, it appears to be running, I can not trace into the line.

Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Molando,

1 ) You can define thread's timeouts from the server by assigning some value to the connection's ReadTimeOut property.

procedure TForm1.IdFTPServer1Connect(AThread: TIdPeerThread);
  AThread.Connection.ReadTimeOut := 10;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MolandoAuthor Commented:
As nobody can answer my question about connection counting, assigning all points to answer about timeouts.
You can know the connection count by yourself. You just need to implement your own connection list. Please take a look at the Indy's "Chat" demo. This is a good example for you to learn what you need to do. Basically, you just need to add a new item to your own list in TIdFTPServer's OnConnect. Then remove it in OnDisconnect. That's all.

If you don't have Indy demos, you can download it from


Oktay Sancak
MolandoAuthor Commented:
This is what I found out:
  l : Tlist;
  NumberOfConnections : integer;

  l := ftpserver.ActiveThreads.locklist;
  numberofconnections := l.count;

A bit of an odd way to do things, but no more weird 'freezing' now.

I'm happy to hear that your problem solved :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.