473,395 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1767
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Corne Oosthuizen | last post by:
I'm writing a Telnet Server application using Asynchronous sockets. I spawn a listener thread to handel incomming connections and create a separate client socket for each new connection. I...
6
by: ... | last post by:
Does anyone know a good tutorial on asynchronous programming in .net AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topic I...
6
by: Toralf Kirsten | last post by:
Hi, we are using a test and a production dbms, separately. The test db is installed on Win2K DB2 UDB V8.1.0. The prod. db is running under Redhat Linux 9 and also uses DB2 V8.1.0. My application...
2
by: TrtnJohn | last post by:
I have a multi-threaded class that I am creating that needs needs to raise events when certain asynchronous events occur. I would always like the events to be raised to the primary UI thread of...
0
by: GS | last post by:
Hello, I'm trying to implement asynchronous call to COM interface below and having trouble understanding what C# code will allow me to update progress bar while call is running. I have an object...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
3
by: sherifffruitfly | last post by:
Hi, I'm using a provided api to download some information (from Bloomberg), which goes into a dataset. I want to save the dataset info back into the database. The problem is that the...
0
by: Bishoy George | last post by:
Hi, I have a asp.net 2.0 web application. I want to implement the asynchronous model through http handler in web.config ...
5
by: Scott M. | last post by:
Am I wrong, or is invoking a web method via a different thread and making an XmlHttp request both different ways of making asynchronous web requests. One just uses the Web Service architecture...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.