Networking Forums

Networking Forums > Computer Networking > Linux Networking > Need some hints for DLing large files in C...

Reply
Thread Tools Display Modes

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

 
 
dreamvigile
Guest
Posts: n/a

 
      07-18-2003, 06:45 PM
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
 
 
 
 
Alexander Clouter
Guest
Posts: n/a

 
      07-25-2003, 11:20 PM
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 <(E-Mail Removed) >, 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
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
distribute large files nico Windows Networking 0 06-02-2010 10:41 AM
Cannot download large files Daniel CLEMENT Windows Networking 0 04-22-2006 09:26 AM
transfer of large files Mikey Wireless Networks 0 10-24-2005 02:11 PM
problems with large files Michael Surette Linux Networking 15 08-04-2005 09:30 PM
parsing very large tcpdump files AA Linux Networking 1 12-20-2004 08:16 AM



1 2 3 4 5 6 7 8 9 10 11