Need some hints for DLing large files in C...

This is a discussion on Need some hints for DLing large files in C... within the Linux Networking forums, part of the Linux Forums category; Hi, when recv is used in C to download large (several megabyte) textfiles from an FTP data port, there tend ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-18-2003
dreamvigile
 
Posts: n/a
Default Need some hints for DLing large files in C...

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
  #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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:21 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0