> On Feb 4, 2015, at 8:21 PM, Graham Cox <graham....@bigpond.com> wrote:
> 
> Do you or anyone else know if there's some inherent limit to the number of 
> simultaneous sockets that can be opened? I'm supposing that there's a 1:1 
> correspondence between a NSURLSession and a socket, because of the 
> description against [NSURLSession resetWithCompletionHandler:] says:
> 
> "This method empties all cookies, caches and credential stores, removes disk 
> files, flushes in-progress downloads to disk, and ensures that future 
> requests occur on a new socket"
> 
> This implies that there's a socket associated with the session.

Network connections use sockets. Sockets use file descriptors. There is a 
per-process limit on the number of open file descriptors. 

You can use getrlimit(RLIMIT_NOFILE, …) to query the limit in your process, and 
setrlimit(RLIMIT_NOFILE, …) to attempt to raise it. The default limit may be as 
low as 256, depending on OS version and on how the process is launched. (Note 
that each two-way network connection uses two file descriptors.) setrlimit() 
should be able to raise the file descriptor limit to a few thousand unless your 
system administrator is mean.

If you hit that limit you should see errors from various network API. File a 
bug report if you find some API that causing weird crashes instead of failing 
gracefully or halting with an appropriate error message when you run out of 
file descriptors.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to