Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Not 'recreated', but what _can_ happen is that you call an ftp command: ``$ftp->cmd(@args);''   which, as you know, is translated by perl as: Package::cmd($ftp, cmd, @args) ((here package is Net::FTP::...)).

Inside cmd($ftp, ...), it does an ``undef $_[0];'' if, and only if, it discovers a broken connection.

Next time you want to do an ftp cmd, you retrieve your _stored_ $ftp, (which is still defined and therefore still pointing to the right package::funcs) and send off another command.   ...Result, it hangs...

For instance, here's the ``put()'', I've used for a couple of years in my wrapper code:
# put: return ok = '' if 'no permission' error (ie, don't retry) sub put { $_[0]->SUPER::put(@_[1..$#_]) # rtns ok/!ok;$_[0] undef'd if abort or check($_[0]) # $_[0] can be undef'd here to hangup }
(and in ``check()'':)
. . . if ($code == 000 || # got here w/ no resp $code == '021' || $code == 421 || # server timeout || abort $code == 425 || # connection not opened ('out of ports'?) $code == 150) { # intermediate result (never finished) $code < 100 and warn " No response (Timeout?).\n"; 150 == $code and warn "\tTimed out in mid-operation.\n"; 421 == $code and warn "\tServer disconnected.\n"; 425 == $code and warn "\tRestarting to clear connections.\n" and sleep 10; warn "attempting to reconnect? ...\n"; undef $_[0]; return undef; } if ($code == 530) { # not logged in! ** needs to croak() ** die "Can't seem to login! (check ~/.netrc file or give name and password on command line?). (I'm dieing) \n"; } if ( $code == 550 # dir/file not available (non-exist, no perms) || (500 <= $code && $code <= 504) # syntax errors || $code == 553 # illegal file name || $code == 452 || $code == 552 ) { # out of space(552: quota) return ''; } if ($code == 426 # closed early || $code == 450 || $code == 451 # file busy, srvr local error || $code == '051') { # added this: local rcv error warn "\tTemporary failure, retrying...\n"; sleep 12; return undef; # retry }


  p


In reply to Re: Re: Re: Net::FTP Wrapper: TCP problem by petral
in thread Net::FTP Wrapper: TCP problem by graq

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-24 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found