Low-level FTP upload with progress

Discussion in 'Open Source Projects' started by brathbone, Feb 10, 2008.

  1. brathbone

    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,

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    Thank you for sharing this valuable code.
    I'm sure happy that an FTP expert has joined our community ;)
  3. brathbone

    brathbone Member Licensed User

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

  4. giannimaione

    giannimaione Well-Known Member Licensed User

    good job :sign0098:
  5. geo-rge

    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 ?

    George Mu'ammar
    Last edited: Jun 7, 2009
  6. Smee

    Smee Well-Known Member Licensed User

    Excellent code.
    Thanks very much for this. Very instructive
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice