D
dreamvigile
Hi,
when recv is used in C to download large (several megabyte) textfiles
from an FTP data port, there tend to be discrepancies in the amount of
data downloaded (too much, too little...) One of the problems is, an
FTP data port tends to send all the data at once, then immediately
hang up. What is a good procedure for obtaining the data? my basic
strategy is:
check if recv returns -1
if so, check if errno == EAGAIN (the socket is nonblocking)
if so, return to step 1 after a few fractions of a millisecond
if not, assume file download is complete
if not, read as much data as possible without blocking
One of the things that would help would be, on the last recv where you
get that last bit of data and the ftp data port closes the connection,
what does recv return? -1 because the connection snaps shut, or a
positive number because it read data?
Thanks very much in advance
when recv is used in C to download large (several megabyte) textfiles
from an FTP data port, there tend to be discrepancies in the amount of
data downloaded (too much, too little...) One of the problems is, an
FTP data port tends to send all the data at once, then immediately
hang up. What is a good procedure for obtaining the data? my basic
strategy is:
check if recv returns -1
if so, check if errno == EAGAIN (the socket is nonblocking)
if so, return to step 1 after a few fractions of a millisecond
if not, assume file download is complete
if not, read as much data as possible without blocking
One of the things that would help would be, on the last recv where you
get that last bit of data and the ftp data port closes the connection,
what does recv return? -1 because the connection snaps shut, or a
positive number because it read data?
Thanks very much in advance