gpt4 book ai didi

iphone - 哪个更好地获取文件 - iOS 代码中的 FTP 或 HTTP?

转载 作者:行者123 更新时间:2023-11-28 22:05:39 25 4
gpt4 key购买 nike

我必须从 FTP 中提取一组图像。

我已经通过只提供图像的服务器 url 尝试了与 tomcat 服务器相同的事情,它看起来又快又好。为了研究从 FTP 服务器拉取的 FTP 文件,从苹果公司得到了一个样本 SimpleFTPSample

示例中有从FTP拉取图片的代码,但是拉取图片太慢了。

为什么一张图片要花这么多时间?如果我必须获得一些图像集,我无法想象时间延迟?

谢谢,东华

最佳答案

作为Daniel states here :

What makes FTP faster:

No added meta-data in the sent files, just the raw binary

Never chunked encoding "overhead"

What makes HTTP faster:

reusing existing persistent connections make better TCP performance

pipelining makes asking for multiple files from the same server faster

(automatic) compression makes less data get sent

no command/response flow minimizes extra round-trips

Ultimately the net outcome of course differ depending on specific details, but I would say that for single-shot static files, you won't be able to measure a difference. For a single shot small file, you might get it faster with FTP (unless the server is at a long round-trip distance). When getting multiple files, HTTP should be the faster one.

使用以下委托(delegate)方法来跟踪上传进度:

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite

totalBytesWritten / totalBytesExpectedToWrite gives me the upload percentage.

关于iphone - 哪个更好地获取文件 - iOS 代码中的 FTP 或 HTTP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16169398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com