B
Brendan
I am trying to download a file within a very large zipfile. I need two
partial downloads of the zipfile. The first to get the file byte
offset, the second to get the file itself which I then inflate.
I am implementing the partial downloads as follows:
con = ftp.transfercmd('RETR ' + filename, rest_offset) # the data
socket
while True:
block = con.recv(blocksize)
# stop transfer while it isn't finished yet
if bytes_recv >= buf_length:
break
elif not block:
break
buf = ''.join([buf, block])
bytes_recv += len(block)
con.close()
My problem is that even though the socket is closed, I have no way to
receive the 226 response from server so I can proceed with the next
download. Of course I could close the ftp connection entirely and
open a new one, but I am hoping to avoid doing so.
partial downloads of the zipfile. The first to get the file byte
offset, the second to get the file itself which I then inflate.
I am implementing the partial downloads as follows:
con = ftp.transfercmd('RETR ' + filename, rest_offset) # the data
socket
while True:
block = con.recv(blocksize)
# stop transfer while it isn't finished yet
if bytes_recv >= buf_length:
break
elif not block:
break
buf = ''.join([buf, block])
bytes_recv += len(block)
con.close()
My problem is that even though the socket is closed, I have no way to
receive the 226 response from server so I can proceed with the next
download. Of course I could close the ftp connection entirely and
open a new one, but I am hoping to avoid doing so.