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

Hello,
     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
  try
    if ftpserver.active  and (ftpserver.Threads.LockList.Count = 0) then begin //the program dies here
      ftpserver.Active := false;
        ftps := false;
      end else good := false;
  except
    good := false;
  end;
  end;

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
                  Molando.
LVL 2
MolandoAsked:
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.

ceoworksCommented:
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);
begin
  AThread.Connection.ReadTimeOut := 10;
end;
0

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.
0
ceoworksCommented:
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 http://www.projectindy.org/DemoDownloads/Indy9Demos_26Oct04.zip

Regards,

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

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

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

0
ceoworksCommented:
I'm happy to hear that your problem solved :)
0
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
Delphi

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.