[Tutor] FTP Bug?

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Sun, 18 Mar 2001 05:44:30 -0800 (PST)


On Sat, 17 Mar 2001, Britt Green wrote:

> Well, my FTP program that I've been working on is almost done. It 
> works...almost! Occasionally when I run it I get this error message:

> error: (10054, 'Connection reset by peer')

If your FTP program is idle (the adjective, not the editor), I think ftp
servers are free to reset the connection, since it looks like it's not
being used.

Not quite sure what do to about this, as even Internet Explorer shows this
to me every once in a while.  *grin* My suggestion is to use a try/except
block to detect this situation, and if it occurs, to try to reestablish
the connection and go for it again.  So something like:

###
try:
    ## Do stuff
except socket.error:
    if not reestablishConnection(): print "Oh no!"
###

(Although there's probably a little more code involved than this.)  Hope
this helps!