Low-level FTP upload with progress

brathbone

Member
Licensed User
Greetings to the Basic4PPC community,

This is my first post, and I would like to thank all of you for the work you've done. Basic4PPC is a fine product. Helpful posts in the forum, and open-source projects made my transition to Basic4PPC a breeze.

I needed to prototype a FTP-based application and was up and running quickly, but I really needed to show progress during FTP uploads. After searching the forum and seeing that the built-in FTP methods are synchronous, which makes perfect sense for simplicity's sake, I decided to port my FTP socket code from REALbasic to Basic4PPC and make it open-source.

Though the project currently only does uploads, I will be working on downloads in the near future.

I've tested with Windows and UNIX FTP servers, and so far all is well. There is certainly a good amount of work left to be done, but this should be a really good start.

What this project does:

Provides PASV mode binary FTP file uploads with progress.

Uses network.client.DataAvailable to provide a mostly complete, client-side FTP implementation.

Passive (PASV) mode port is used for firewall friendliness. For those of you not familiar with PASV vs. PORT mode I will provide a brief explanation. FTP uses two connections: a command socket and a data socket. The command socket connects outbound from the client on port 21 to the server, which is listening for connections on port 21. In Active (PORT) mode, the server would connect the data socket back to the client, which would have to be listening for this connection. Many firewalls support this, but there can be problems. In PASV mode, the server listens on a new random port and sends that random port to the client via the command socket. The client then connects the data socket outbound on the dynamic port, thus all connections from the client are outbound and most client-side firewall issues should be averted.

Any comments, bug reports and/or contributions will be welcome and appreciated. I hope some of you find this useful.

Best wishes,
 

Attachments

  • ftp_progress_v1.zip
    50.2 KB · Views: 927

brathbone

Member
Licensed User
Thanks Erel. I'm darn glad to be here and look forward to doing some cool things.

:)
 

geo-rge

New Member
Licensed User
FTP upload not working with WM5

Hi and thanks for this code!

It works with WM5 but not with WM4. Unfortunately we have hundreds of ppcs and I have to get some backward compatibility.

The problem I get is that the file is uploaded but when you close the connection the transmission does not complete properly somehow the file gets deleted at the server side.

Has anyone had any experience with this ?
Thanks

George Mu'ammar
 
Last edited:

Smee

Well-Known Member
Licensed User
Longtime User
Excellent code.
Thanks very much for this. Very instructive
:icon_clap::icon_clap:
 
Top