Board index » delphi » need help on disconnecting client

need help on disconnecting client


2007-07-10 02:22:04 PM
delphi58
hi all, could somebody show example code snippet to how to disconnect
one client from the ftp server (indy 10.1.6) if i know address and port
which i want to disconnect?
thanks
 
 

Re:need help on disconnecting client

following I have tried, but after the correct client is disconnected
succesfully the idftpserver hangs and is not able to close even. so
something more needs to be done than just rising exception as in this test:
if idftpserver1.Contexts<>nil then
with idftpserver1.contexts.locklist do
try
for p:=0 to count-1 do
if
(tidcontext(idftpserver1.Contexts.LockList[p]).Binding.PeerIP = addr) and
(tidcontext(idftpserver1.contexts.locklist[p]).binding.PeerPort = port) then
begin
tidcontext(idftpserver1.Contexts.LockList[p]).DoException(exception.create('Disconnected'));
messagedlg('Client disconnected', mtinformation, [mbok], 0);
exit;
end;
finally
idftpserver1.contexts.UnlockList;
end;
please help!
 

Re:need help on disconnecting client

"API" <XXXX@XXXXX.COM>writes
Quote
following I have tried, but after the correct client is disconnected
succesfully the idftpserver hangs and is not able to close even.
You are calling LockList() too many times, and you are not calling
UnlockList() for each LockList(). So you are deadlocking the server because
the list is remaining locked permanently. You should be calling LockList()
only once. See my example in the other thread you started for this issue.
Quote
something more needs to be done than just rising exception
as in this test:
You can not raise an exception in the context like you are attempting to do.
That is not what DoException is for().
Gambit
 

Re:need help on disconnecting client

Remy Lebeau (TeamB) kirjoitti:
Quote
You are calling LockList() too many times, and you are not calling
UnlockList() for each LockList(). So you are deadlocking the server because
the list is remaining locked permanently. You should be calling LockList()
only once. See my example in the other thread you started for this issue.
Ok, now got this. Took some time to understood that locklist (had to
open source to see what this was about).
Quote

You can not raise an exception in the context like you are attempting to do.
That is not what DoException is for().


Gambit
hehe, yes. i don't want to just fire event here.
Thank you for the great example on previous and pointing out the
problems on this how i tried to do this. You're doing great job
here!