TFTPClient Last Updated: 01/27/2007 |
Frequently Asked Questions for TFTPClient:
- What is it?
- Aborting without disconnecting
- BINARY property
- Deleting several files
- Dir command
- Filesize is 0 bytes after a download
- FTP client is a server
- How do I resume an upload with TFTPCli?
- Kylix
- LIST command
- How to assign a range of ports to FTPCli?
- Receive many files in a single connection
- Sending a message to the server
What is it?
Francois Piette francois.piette@overbyte.be 21.09.1998 |
TFtpClient is basically an extension of the lower level TwSocket object. Not directly inherited, this class has at least 2 instantiations of the TwSocket class for both the control connection and the data connection. This class adheres to the ftp RFC specifications.
|
Aborting without disconnecting
Albert Fowler afowler@starband.net 21/07/2001 |
> I would like to abort current action (eg. downloading or uploading
> file) without client being disconnected from a server. Is there any way > I could do this using TFtpClient? There is a boolean value that is writeable in the onProgress event. Set this to true. This will cancel gracefully. |
BINARY property
Davie smatters@smatters.com 25/02/2001 |
> Can I just set the BINARY property
NO, because that will not send the command to the FTP SERVER to let it know about the file type. In order to do that properly, you need to do: PREFERRED: FTPClient.TypeBinary; (or FTPClient.TypeBinaryAsync;) or FTPClient.TypeASCII; (or FTPClient.TypeASCIIAsync;) OR (older way, more prone to errors) FTPClient1.Binary := True; FTPClient1.TypeSet; (or FTPClient1.TypeSetAsync; ) |
Deleting several files
Francois PIETTE francois.piette@overbyte.be 22/09/2001 |
> For the moment, I'm trying to delete several files selected, only files
> and not directories (+ subdirectories and files). > > I made a list with the files selected. After that, I think to use a loop > to delete the selected file one by one. But the problem I have, it's ok > course, the loop is tos fast and in the second pass in this loop, I > receive an error, FTP component not ready or already in use (I don't > remember exactly). > > Could you put me on the way to do that. I tried with Dele and DeleAsync > with a flag to wait the end of the previous Dele, and DeleAsync.But > nothing work. Don't use a loop ! Use async function and OnRequestDone event. Let's assume you have a list of all files to delete. Then write a function which takes the first entry in the list and send DELE command (async version) and exit. Then when DELE is done, OnRequestDone is fired. In the event handler, you remove the first item in your list and call the first function again if the list is not empty. That's all ! If you have more operations (and you have !), then use a "state" variable to know what is the next operation. You have a state to change working directory, another one to dele a file. In the OnRequestDone event, you check the current state, go to next state and do appropriate processing. This technique is called "finite state machine". You should look at MailRcv sample program. The "Get All" button has similar code to retrieve all available messages from pop3 server without using a loop but using event driven code. |
Dir command
Francois PIETTE francois.piette@overbyte.be 21/07/2001 |
> Listing remote directory with FtpClient creates local text file containing > remote list result. But content of the text file varies depending on the > specific host. Is there any way I could exactly determine which colums is > remote filename, remote size, date etc ? This is how FTP standard is: non standard about directory listing :-( Yoy could use SYSTEM command to query remote FTP server system and based on that system write a specific parsing routine. |
Filesize is 0 bytes after a download
Davie smatters@smatters.com 14/04/2001 |
1. You timeout was set to 30 seconds and trying to connect to that SLOW server timed out many times, although it did connect a couple of times. So INCREASE the timeout to at least one minute.
2. You have setup your input parameters to the method calls in ICS too far in advance!!!! Always setup the parameters RIGHT BEFORE the method call, because you never know what fields will end up getting modified by ICS. For example, your CWD could have wiped out your LocalFileName (the CWD doesn't but you don't know which do and which don't) So a good practice to to set them up as you need them, NOT at the top of the whole thing. 3. If you expect to get data saved to your hard drive you NEEEEED to NOT have the DisplayFileFlag set. IE: Make sure it's made FALSE. I noticed that you had set it to true. All that will do is allow you to display the data as it's being retrieved, and it bypasses being saved to disk. So, once these changes are made you will notice you app works great. |
FTP client is a server
Francois Piette francois.piette@overbyte.be 15/11/2004 |
I used FtpClient in my program. I have ZoneAlarm in my computer. when I want transfer files between server program, Zone Alarm show the attached picture, that my program want to be as a server. (but I use FtpClient NOT FtpServer)
Use passive mode ! A FTP client in default (active) mode becomes a server (Yes !) for the data channel. In passive mode the client remains a client. This is how FTP protocol has been designed years ago. |
How do I resume an upload with TFTPCli?
Albert Fowler and Heedong Lim hdlim@www.kis21.com 25/03/2002 |
If the server supports the REST command, you can use
Otherwise, use the following method:
Of course you will have to set all other related properties before and handle the onRequestDone event. |
Kylix
Francois PIETTE francois.piette@overbyte.be 21/04/2003 |
Can we program ftp application whith ICS for Kylix
Yes but the FTP component has not been ported yet. So you either implement yourself FTP protocol using TIcsSocket (TWSocket ported to Kylix) or better you port the existing ICS FTP component to Kylix using TIcsSocket instead of TWSocket. Both component are very close in their properties, methods and events. The major difference is that Linux doesn't support async socket by itself, so TIcsSocket create a background thread to achieve async operation (non-blocking). So the events such as OnDataAvailable are called in the context of this background thread. This makes not too much differences except if you have to update the user interface from an event handler because some GUI component are not thread safe. |
LIST command
Andy Wilk castor.vulgaris@gmail.com 14/5/2005 |
How to parse the output returned by FTP server in response to LIST command?
While searching to solve the question, I found ftpparse by D. J. Bernstein (http://cr.yp.to/ftpparse.html) Written in plain C it parses the response of vast number of FTP servers being fed to it line by line. It will be of great help for those who programs with C++Builder. But if you are a fairly advanced Delphi programmer, you can convert ftpparse.h to pascal unit, compile ftpparse.c to ftpparse.obj (with freely available Borland C++ command line tools) and merely link to it from ftpparse unit with {$L} directive. |
How to assign a range of ports to FTPCli?
Francois PIETTE francois.piette@overbyte.be 24/12/2001 |
You have to change procedure TCustomFtpCli.PortAsync which assign '0' to the port. '0' means the OS will choose the port. Implement some mechanism to cycle thru your port range. Add a property DataPortRangeBegin and DataPortRangeEnd. If both values are 0 then the component will use OS assigned port, otherwise the component will cycle thru the range. Don't forget to check if the port is already used in case of a lot of components are used to do a lot of simultaneous FTP transfers.
|
Receive many files in a single connection
Francois Piette francois.piette@overbyte.be 21.09.1998 |
Connect, Cwd, Get, Get, Get, and Quit. Use the xxxAsync commands.Use the OnRequestDone event to start the next Get.
|
Sending a message to the server
Sven Schmidts schmidts@flat2serv.de 18/08/2001 |
> Is it possible to send a message via the FTP client to the server ?
1.) Yes, send a "SITE MSG Text" to the server. In the Proc "OnClientCommand" parse the lines for Keyw. "SITE" and Params for "msg". Answer then with a "200 OK". To send a msg from server to client just send "214 Text here". 2.) Using QUOTE, the FTP client can send anything (well almost) to the FTP server. |