Jenda has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone. In a service (for the Unix folk: daemon) I am copying lots of smallish files with FTP (using Net::FTP). I'm copying them one by one which takes a lot of time so I'd like to speed it up by opening several connections and sending several files at once. I tried to use Win32::Internet asynchronously, but wasn't able to get anywhere.

Did anyone try succeed to FTP with Win32::Internet asynchronously? Or with some other module?

I can fork() in the service and create a few worker threads (yeah, it'd be threads only under Win32) and pipe them the names of the files to send (I have done this kind of thing already), but I'd like to know if there is an easier solution.

I'm using ActivePerl v5.6.1 build 631 under Win2k Pro&Server

  Thanks, Jenda

== Jenda@Krynicky.cz == http://Jenda.Krynicky.cz ==
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
      -- Rick Osborne, osborne@gateway.grumman.com

Replies are listed 'Best First'.
Re: Asynchronous FTP
by yodabjorn (Monk) on May 20, 2002 at 23:34 UTC

      I do know how to fork(), I asked whether someone knows of something that would let me FTP several files at once WITHOUT having to fork() explicitely. Parallel::ForkManager is not a good solution to the thing I need, I don't want to fork() for each file to be uploaded. If I end up forking I'll prefork a few worker threads sharing a command pipe and pipe them commands. I've done that sort of thing already.

      I'll post here if I find something.

        Jenda@Krynicky.cz

Re: Asynchronous FTP
by Aristotle (Chancellor) on May 21, 2002 at 19:30 UTC
    LWP::Parallel seems to be what you want. It's only sparsely documented though so I'm not sure whether it suits your needs but it does advertise "parallel HTTP and FTP access" in the description.

    Makeshifts last the longest.

      Thanks, I looked there. It doesn't seem to help much though since I need to "push" files and LWP::Parallel only allows me to "pull" them.

      I guess I'll do it completely different at last. I'll zip the files up, upload the zip and then a 0B "done flag" file and run another service on the other side that'll take the ZIP and unpack it. It'll be quicker and safer anyway, that way I can

      • extract into TEMP
      • delete old
      • move new
      and there'll be no time when the file is incomplete (and the time it's not present at all will be very short)

      If anyone has a nice solution for the async FTP I am still interested though :-)

        Jenda@Krynicky.cz

        Here's a suggestion for the way you're doing it right now: upload with a bogus filename, then send RNFR BOGUS.ZIP and RNTO TARGET.ZIP. No 0 byte file kludges here..

        Makeshifts last the longest.