使用多个线程下载单个文件 [英] downloading a single file using multiple threads

查看:57
本文介绍了使用多个线程下载单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用多个线程下载单个文件...

我如何单独指定一个特定的字节范围单个

大文件...例如说如果我只需要字节范围从

500000到3200000的文件,其大小为20MB ...

如何请求下载直接从500000字节开始...

谢谢你

欢呼

hi

i''m downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...
thank u
cheers

推荐答案

< ke **************** @ gmail.comwrote:
<ke****************@gmail.comwrote:

我正在使用多个线程下载单个文件...

如何从单个

大文件中单独指定特定的字节范围..例如,如果我只需要字节范围从

500000到3200000的文件,其大小为20MB ...

我如何请求下载直接启动在500000字节...
i''m downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...



这完全取决于protoco你正在使用你能给我们更多的信息吗?


-

Jon Skeet - < sk *** @ pobox.com> ;
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复该组,请不要给我发邮件

That completely depends on what protocol you''re using. Could you give
us more information?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


< ke ************* ***@gmail.com在留言中写道

news:11 ********************** @ n76g2000hsh.googlegr psps.com。 ..
<ke****************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...

hi


我正在使用多个线程下载单个文件...

如何从单个

大文件中单独指定特定的字节范围...例如,如果我只需要字节范围从

500000到3200000一个大小为20MB的文件...

如何请求直接从第500000字节开始的下载...

谢谢你

欢呼
hi

i''m downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...
thank u
cheers



简单回答:除非你实现了客户端/服务器,否则你不能以文件的形式下载*文件

协议。

如果通过* download *你的意思是*读*来自fileserver的文件并将副本保存到

本地文件系统,然后您可以使用System.IO命名空间类

问题是 - 是什么让您认为您需要多个线程来*下载*一份文件?如果

你认为你可以通过这样做加快下载速度,那么你错了。瓶颈

将始终是网络,所以如果你在一个块中下载文件,你将获得最大的b / b $ b吞吐量,引入多个线程实际上会减慢整个过程。


Willy。


Simple answer: you can''t *download* a file in chunks, unless you implement a client/server
protocol for this.
If by *download* you mean *reading* a file from a "fileserver" and saving a copy to the
local filesystem, then you can use System.IO namespace classes
The question is - what makes you think you need multiple threads to *download* a file? If
you think you can speed-up the download by doing this, then you are wrong. The bottleneck
will always be the network, so if you download the file in one chunk, you''ll get the maximum
throughput, introducing multiple threads will actually slowdown the whole process.

Willy.


3月28日上午10:30,Willy Denoyette [ MVP]"

< willy.denoye ... @ telenet.bewrote:
On Mar 28, 10:30 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:

< keerthyragavend ... @ gmail。消息中写道


新闻:11 ********************** @ n76g2000hsh.googlegr psps.com ...
<keerthyragavend...@gmail.comwrote in message

news:11**********************@n76g2000hsh.googlegr oups.com...

hi
hi


我正在使用多个线程下载单个文件。 。

如何从单个

大文件中单独指定一个特定的字节范围...例如,如果我只需要字节范围从

500000到3200000的文件,其大小为20MB ...

我如何申请downl oad直接从500000字节开始...

谢谢你

欢呼
i''m downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...
thank u
cheers



简单回答:你可以除非你为此实现客户端/服务器

协议,否则不要下载*文件。


Simple answer: you can''t *download* a file in chunks, unless you implement a client/server
protocol for this.



请注意,已经有* *支持此协议的协议,包括

FTP和HTTP,两者都可选择与服务器有关。

Note that there already protocols which *do* support this, including
FTP and HTTP, both optionally as far as the server is concerned.


问题是 - 是什么让你认为你需要多个线程来*下载*一个文件?如果

你认为你可以通过这样做加快下载速度,那么你错了。瓶颈

将始终是网络,所以如果你在一个块中下载文件,你将获得最大的b / b $ b吞吐量,引入多个线程实际上会减慢整个过程。
The question is - what makes you think you need multiple threads to *download* a file? If
you think you can speed-up the download by doing this, then you are wrong. The bottleneck
will always be the network, so if you download the file in one chunk, you''ll get the maximum
throughput, introducing multiple threads will actually slowdown the whole process.



这取决于 - 某些服务器可能会对每个连接进行限制,此时

指向多个连接可能是有意义的(尽管

有些顽皮)。此外,以更高级的方式,如果通过多个镜像提供相同的文件

,从不同的镜像中获取不同的
位可能是有意义的。


这是一件相当常见的事情 - 很多网络下载经理

这样做。


Jon

That depends - some servers may throttle per connection, at which
point it may make sense to have multiple connections (although
somewhat naughty). Also, in a more advanced way, if the same file is
available through multiple mirrors, it may make sense to get different
bits from different mirrors.

This is a fairly common thing to do - a lot of web "download managers"
do it.

Jon


这篇关于使用多个线程下载单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆