View Single Post

  #2 (permalink)  
Old 07-26-2003
Alexander Clouter
 
Posts: n/a
Default Re: Need some hints for DLing large files in C...

If you were close to a C programmer you would probably type 'man recv'
however that but that would be far too easy...... :-/ Most (if not all do)
functions return -1 (TRUE) if the function completes sanely with no errors,
so what do you think happens when the return valus is not -1?

Other suggestions are are you checking the lengths of the buffers?

Then again, simply using Google for two seconds with about three well choosen
keywords would of given you the answer, rather than wasting the bandwidth of
every newsserver in the world, news client and then having to wait 24 hours
for a reply; such as mine to your problem.

Is it September already......?

Regards

Alex

In article <657d7b28.0307181045.5fae0942@posting.google.com >, dreamvigile wrote:
> 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 data in chunk
>
> 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

Reply With Quote