Re: [twsocket] FTPCli in thread
*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 Hi, 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 thread. 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: http://www.magsys.co.uk/delphi/magxfer.asp 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. Angus -- 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
Re: [twsocket] FTPCli in thread
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 Hi, 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 thread. 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: http://www.magsys.co.uk/delphi/magxfer.asp 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.) timeoutTimer.Set(6); FunctionDone = false; FtpClient-DirAsync(); while (!FunctionDone) { FtpClient-MessagePump(); Sleep(0); // Just for testing. if (timeoutTimer.IsTime(GetTickCount())) // Returns true if we have timeout. { FtpClient-Abort(); break; } } 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? /Fredrik -- 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
Re: [twsocket] FTPCli in thread
We are running this code for testing, as it shows the issue better: (Code has been stripped of error handling, etc.) I don't see anything wrong with your code sample, but you would be better using the tried and tested code from the WaitUntilReady function which duplicates what you are trying to do, but tests the State property to see when something is finished. Or just use the Dir sync function which calls WaitUntilReady. Sometimes TCP/IP does not behave as you expect when connections don't close properly, which seems to be your problem, which is why TMagFtp has the ability to repeat functions on failure. Angus -- 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
[twsocket] FTPCli in thread
Hi, 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 thread. I know we should have some kind of message pump running in the thread, but would it be ok to have something like this? FtpCli-DirAsync(); while (!done) { FtpCli-MessagePump(); } ::OnRequestDone(...) { done = true; } Are there any examples or posts in the mailing list that may give me more information around this? Regards, Fredrik -- 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