471,596 Members | 986 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,596 software developers and data experts.

Asynchronous HTTP Download

Hello everybody,

I need to write a HTTP client capable of downloading files using the
HTTP protocoll. But downloading is one of my problems. I'm new to VB.net
and I know there's a framework offering a solution for almost every
problem. But for me it's a bit complex.

So what I need:
I need a way to download files asynchronously. In VB6 I solved this
problem with a self-written component using sockets. As of the large
amount of classes in the net-framework I was first looking for a
built-in solution offering me the same functionality. I found various
samples working with HttpWebRequest and a StreamReader. But makeing this
asynchronous using a timer calling the Read method of the StreamReader
does not really make sense.

So is there a way to implement it that way that there occurs an event
when new data has been read from the server or do I have to implement it
using Sockets?
Thanks in advance,

Stefan

--
___________________________________www.VBTricks.de .vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
__________________________________________________ ___
Nov 21 '05 #1
2 1683
I just wrote one for a client using the HttpWebRequest class.

I created a download worker thread that requested a chunk of data from the
read stream. It tends to read smaller chunks than desired on my system but
careful byte count management seems to work.

The events were provided in the form of a couple of delegates that passed a
custom event argument back containing filesize and percentage done, time
remaining and so-on.

I'd post the code but it's not mine.

HttpWebRequest is definitely the way to go.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"VBTricks.de.vu Webmaster" <no****@thisserverdoesntexist.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
Hello everybody,

I need to write a HTTP client capable of downloading files using the HTTP
protocoll. But downloading is one of my problems. I'm new to VB.net and I
know there's a framework offering a solution for almost every problem. But
for me it's a bit complex.

So what I need:
I need a way to download files asynchronously. In VB6 I solved this
problem with a self-written component using sockets. As of the large
amount of classes in the net-framework I was first looking for a built-in
solution offering me the same functionality. I found various samples
working with HttpWebRequest and a StreamReader. But makeing this
asynchronous using a timer calling the Read method of the StreamReader
does not really make sense.

So is there a way to implement it that way that there occurs an event when
new data has been read from the server or do I have to implement it using
Sockets?
Thanks in advance,

Stefan

--
___________________________________www.VBTricks.de .vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
__________________________________________________ ___

Nov 21 '05 #2
But when implementing it using a timer, it freezes the applikation (when
timer interval is set too small). Otherwise, it will not use the full
speed of the connection (when timer interval is set to high).

Is there no way to be informed by HTTPWebRequest when new data has arrived?
Stefan
--
___________________________________www.VBTricks.de .vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
__________________________________________________ ___
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Corne Oosthuizen | last post: by
6 posts views Thread by ... | last post: by
6 posts views Thread by Toralf Kirsten | last post: by
1 post views Thread by dba123 | last post: by
3 posts views Thread by sherifffruitfly | last post: by
reply views Thread by Bishoy George | last post: by
5 posts views Thread by Scott M. | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.