Hi,

Is there a way to regulate how sockets are used by Net::FTP?

To me it sounds like there could be a way to "reuse" sockets since the transfers do not happen in parallell but sequentially.

Situation; I have a dropbox server from which I copy the incoming files to an internal server using a perl script. The script also archives the files and makes a copy to a dev environment on demand and writes these transfers to a database for tracking.

The problem I'm facing is that given hundreds of files every 15 minutes means that the script opens up a truckload of sockets ( nearly 1500 simultaneous open sockets ) for all the put commands.

Here are the FTP specific commands used in the script.

This part is exectuted only once:

$ftp2=Net::FTP->new($host2,Port=>$port,Timeout=>60) or die "Cannot con +nect2 to $host2: $@"; $ftp2->login($user2,$pass2) or die "ftp2: Cannot login ", $ftp->messag +e; $ftp2->binary or die "Couldn't change mode2 to binary!\n";

This code is executed for every file encountered that should be moved, finding the files to be moved is done using File::Find. In the "wanted" loop I call on the archival of the file and then the transfer:

$ftp2->put($file) or my $problem2 = 1;

If there's no way to limit the sockets easily, I would appreciate if you could give me pointers to better ways to do this. I used File::Copy earlier to copy the files over SMB to UNC paths but found the solution to be rather unstable, causing intermittent errors due to unknown reasons ( probably network related ).

Thanks in advance


In reply to limiting the amount of sockets opened by f by Faile

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.