开发者

How many simultaneous (concurrent) network connections does iphone support?

开发者 https://www.devze.com 2022-12-31 06:19 出处:网络
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 NSURLConne

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 start开发者_StackOverflow社区s queuing them?

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.


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.

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..


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.

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.

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消