iphone支持多少个同时(并发)网络连接?

时间:2021-04-29 00:58:44

I can't seem to find this anywhere, but I'm sure there must be an answer...

我似乎无法在任何地方找到这个,但我相信一定有答案......

How many simultaneous HTTP connections can an iphone app service? In other words, if I build and run a bunch of NSURLConnections asynchronously, how many can be in flight before it starts queuing them?

iphone应用服务可以同时连接多少个HTTP连接?换句话说,如果我异步构建并运行一堆NSURLConnections,那么在开始排队之前有多少可以在飞行中?

Also, is there a method to check how many threads are available and/or in use programmatically?

此外,是否有一种方法可以通过编程方式检查可用和/或使用的线程数?

I'm trying to write an intelligent pre-fetching engine, and these limits (if any) would be useful information.

我正在尝试编写一个智能的预取引擎,这些限制(如果有的话)将是有用的信息。

2 个解决方案

#1


10  

The iPhone doesn't start queuing NSURConnections. That's totally your responsibility. The iPhone will start all your asynchronous NSURLConnections in parallel. The only thing that will stop it is your memory :) I recently implemented a connection pool (my solution was based on NSOperationQueue) just because of that. Now I can control parallel connections and my app doesn't crash when loading hundreds of avatar images.

iPhone无法开始排队NSURConnections。这完全是你的责任。 iPhone将并行启动所有异步NSURLConnections。唯一能阻止它的就是你的记忆:)我最近实现了一个连接池(我的解决方案基于NSOperationQueue)就是因为这个。现在我可以控制并行连接,并且在加载数百个头像图像时我的应用程序不会崩溃。

About your second question. I actually don't know about a way to get the list of current threads. I had a look at NSThread API but no sign of an API for that..

关于你的第二个问题。我实际上不知道如何获取当前线程列表。我看了一下NSThread API,但没有API的迹象......

#2


1  

So the reason I assumed there may be a simultaneous connection limit at the mobile OS level is because many mobile browsers enforce one. There are techniques for speeding up loading speed of the mobile version of your website by ensuring that there are as few additional content fetches as possible. Images are the main culprit, but css files, javascript files, etc all require an additional connection.

因此我假设在移动操作系统级别可能存在同时连接限制的原因是因为许多移动浏览器强制执行一个。有一些技术可以确保尽可能少的额外内容提取,从而加快网站移动版本的加载速度。图像是罪魁祸首,但css文件,javascript文件等都需要额外的连接。

In mobile, setting up and tearing down a connection is much more expensive than a single connection with more data, and one technique for improving page load performance is embedding your CSS and javascript in the page itself.

在移动设备中,设置和拆除连接比使用更多数据的单个连接要昂贵得多,而提高页面加载性能的一种技术是将CSS和javascript嵌入页面本身。

It sounds like this limitation may not exist in the OS itself, at least on the iphone platform.

听起来这个限制可能不存在于操作系统本身,至少在iPhone平台上。

As far as an answer to this question, I found this post that discusses the practical limitations of simultaneous connections. It's not a hard limit, but I think it answers the point of the question.

至于这个问题的答案,我发现这篇文章讨论了同时连接的实际限制。这不是一个硬性限制,但我认为它回答了问题的关键点。

Background threads consuming 100% CPU on iPhone 3GS causes latent main thread

在iPhone 3GS上消耗100%CPU的后台线程会导致潜在的主线程

#1


10  

The iPhone doesn't start queuing NSURConnections. That's totally your responsibility. The iPhone will start all your asynchronous NSURLConnections in parallel. The only thing that will stop it is your memory :) I recently implemented a connection pool (my solution was based on NSOperationQueue) just because of that. Now I can control parallel connections and my app doesn't crash when loading hundreds of avatar images.

iPhone无法开始排队NSURConnections。这完全是你的责任。 iPhone将并行启动所有异步NSURLConnections。唯一能阻止它的就是你的记忆:)我最近实现了一个连接池(我的解决方案基于NSOperationQueue)就是因为这个。现在我可以控制并行连接,并且在加载数百个头像图像时我的应用程序不会崩溃。

About your second question. I actually don't know about a way to get the list of current threads. I had a look at NSThread API but no sign of an API for that..

关于你的第二个问题。我实际上不知道如何获取当前线程列表。我看了一下NSThread API,但没有API的迹象......

#2


1  

So the reason I assumed there may be a simultaneous connection limit at the mobile OS level is because many mobile browsers enforce one. There are techniques for speeding up loading speed of the mobile version of your website by ensuring that there are as few additional content fetches as possible. Images are the main culprit, but css files, javascript files, etc all require an additional connection.

因此我假设在移动操作系统级别可能存在同时连接限制的原因是因为许多移动浏览器强制执行一个。有一些技术可以确保尽可能少的额外内容提取,从而加快网站移动版本的加载速度。图像是罪魁祸首,但css文件,javascript文件等都需要额外的连接。

In mobile, setting up and tearing down a connection is much more expensive than a single connection with more data, and one technique for improving page load performance is embedding your CSS and javascript in the page itself.

在移动设备中,设置和拆除连接比使用更多数据的单个连接要昂贵得多,而提高页面加载性能的一种技术是将CSS和javascript嵌入页面本身。

It sounds like this limitation may not exist in the OS itself, at least on the iphone platform.

听起来这个限制可能不存在于操作系统本身,至少在iPhone平台上。

As far as an answer to this question, I found this post that discusses the practical limitations of simultaneous connections. It's not a hard limit, but I think it answers the point of the question.

至于这个问题的答案,我发现这篇文章讨论了同时连接的实际限制。这不是一个硬性限制,但我认为它回答了问题的关键点。

Background threads consuming 100% CPU on iPhone 3GS causes latent main thread

在iPhone 3GS上消耗100%CPU的后台线程会导致潜在的主线程