On 2012-09-19 15:09, Angus Robertson - Magenta Systems Ltd wrote:
*Subject:* [twsocket] FTPCli in thread
*From:* Fredrik Bergström <fredrik...@ko2000.nu>
*To:* twsocket@elists.org
*Date:* Mon, 17 Sep 2012 19:41:01 +0200


I started writing an message to this list about an timeout-issue we
have been having, but I think it may be better for me to first ask
for some guidance on how to run OverbyteIcsFtpCli properly from a
I know we should have some kind of message pump running in the
thread, but would it be ok to have something like this?
TMagFtp from:


uses FtpCli in a thread, and has a demo program to run 200 FTP sessions
simultaneously.  But it uses sync methods, since the thread is dedicated
to FTP and does not have a form to keep responsive.

The most important issue is to create the FTP component in the Execute
method of the thread so the message window has the correct context, and
set Multithreaded to true so the ICS message pump is used while waiting
for sync methods to complete.  Nothing more complicated than that.

Thank you for your quick answer.
I have checked through some of the demo-code there and will continue looking a bit later on.
But I think it seems like we are doing that part correctly in our code.

We are running this code for testing, as it shows the issue better:
(Code has been stripped of error handling, etc.)

FunctionDone = false;
while (!FunctionDone)
    Sleep(0); // Just for testing.
if (timeoutTimer.IsTime(GetTickCount())) // Returns true if we have timeout.

FunctionDone is set to true in the FtpRequestDone event handler.

it works most of the time, but sometimes we get the following log (I have kept some CWD and other commands for context):
120919-124506: > CWD /server/C/Users/
120919-124506: < 250 CWD successful. "/server/C/Users" is current directory.
120919-124506: > TYPE A
120919-124506: < 200 Type set to A
120919-124506: > PASV
120919-124506: < 227 Entering Passive Mode (10,1,23,10,235,217)
120919-124506: > LIST
120919-124506: < 150 Connection accepted
120919-124506: < 226 Transfer OK
* Timeout happens after 60 seconds. We call Abort().
120919-124606: ! 54bytes received/sent in 59 seconds (0bytes/sec)

For me this looks like the request works, and that the reply came back. But the FtpRequestDone was not triggered? If I look in the LocalStream it contains the file list data from the server as it should.

Any ideas what this may be? Or where I should look?


To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to