kanak Posted February 10, 2005 Posted February 10, 2005 hi all ... i want to know whether anyone has an idea how download accelerator works... I m tryin to implement a downloading tool ... but what i have noticed in all these downloading manager is that they dont store the incoming data in a byte buffer... instead writing it to a temperory file... i want to know how it is possible... the problem i am facing is that .. i get the size of the data i want to download and allocate the buffer according to the size... the thing work quite fine... but the problem comes when the size of the file is large say around 70 to 80 Mb. .. Since i am declaring a byte buffer of 80 mb size... its making me looose my ram memory until the file downloading finishes... that is the problem .....and sometime the computer go low in virtual memory toooo... so if anyone has an idea of how to over come this problem .. and also any idea on how the download manager do so ... please give me suggestions... thanks in advance Quote
Administrators PlausiblyDamp Posted February 10, 2005 Administrators Posted February 10, 2005 Why not just open a tempory file on disk and as the bytes are received (use a smaller buffer for this) just write them to the file on disk. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jay1b Posted February 11, 2005 Posted February 11, 2005 Download Accelerator doesnt speed up your download, it will actually slow it down. Its just a front for Spyware. Quote
Napivo1972 Posted February 11, 2005 Posted February 11, 2005 Download Accelerator doesnt speed up your download' date=' it will actually slow it down. Its just a front for Spyware.[/quote'] Not always in my humble opinion. If you have multiple servers, which allow you to download portions of a large file (Some ftp�s allow this), you could accelerate the download by requesting part one form the first server part two from the second and so on. Of course this only really works well if the upload speed of the servers is the bottleneck and not the connection of the client. (I believe this is the way Microsoft does it when you update windows) I probably don�t need to explain that if there is one byte of difference for the files on one of the servers you are in trouble. Quote
Jay1b Posted February 11, 2005 Posted February 11, 2005 Yeah some download software can be used for that but 'Download Accelerator' also sends information back about your computer (Spyware) - anything extra being sent back and forth will obviously use your bandwidth. Which is the usual cause of low downloads (although decreasingly often now). Quote
kanak Posted February 11, 2005 Author Posted February 11, 2005 hey where the discussion is going ,... I m using download accelerator.. and i m really satisfied with the speed of download as when it connects to all the 10 mirrors .. the speed rises to 40 to 50 Kbps....so please dont discuss about whether its a spyware or not. my question was .. how to write the bytes recieved from the file which i m downloading from the internet directly into a file... i dont want to use any temperory buffer or byte array..so tell me how to do that.... if possible please help me with the code..... Quote
coldfusion244 Posted February 11, 2005 Posted February 11, 2005 When you receive the data, instead of loading it into memory, just the file, seek to the end and add the data (or I guess append mode would work). Now if you are receiving the data in a non-contiguous manner (i.e. byte 1 is followed by byte 6 followed by byte 3) then I would suggest creating a file of the correct size and making it blank. Then when the data comes in, find which part of the file it is, seek to it and replace the data. Hope this helps, I will try to write some code for you but I am not currently on a machine with .NET. Quote -Sean
kanak Posted February 11, 2005 Author Posted February 11, 2005 I m using the following code ... Public Class Form1 Inherits System.Windows.Forms.Form Shared httpreq As HttpWebRequest Dim res As WebResponse Dim by(10000) As Byte Shared contentlength, i As Integer Dim speed As Integer = 0 Public Sub Download() httpreq = WebRequest.Create(TextBox1.Text) res = httpreq.GetResponse Dim strTemp As String contentlength = res.ContentLength Dim sizeInKB As String = (contentlength / 1024).ToString() Dim fname As String ="hello.dat" Dim sw As FileStream = IO.File.Open(fname, FileMode.OpenOrCreate) Dim f2 As Stream = res.GetResponseStream Dim n, k As Integer Try k = contentlength While k >= 0 'f2.Seek(contentlength - 9999, SeekOrigin.Current) \\The error comes as Seek Operation is not supported on this type of stream n = f2.Read(by, 0, 9999) sw.Write(by, 0, n) Array.Clear(by, 0, 10000) If n = 0 Then Exit While End If k -= n End While Catch ex As Exception MsgBox(ex.Message) Finally f2.Close() sw.Close() End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click download() end sub i m not able to perform seek operation here.. as it throws exception that seek operation can not be performed on this kind of stream..... u can see..i m using a temperory buffer of 10000 bytes ... .. i want to prevent that... is there any solution Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.