I'd have to call setrlimit to bump the count beyond 64K (which is a non-privileged AppStore compatible call).
setrlimit
is a supported API which you can call in any App Store app.
I’m not aware of any meaningful limit to how high you can raise this. However, if you go too far you’ll hit some other limit. For example, for open files, you’ll run out of inodes.
For sockets, you’ll hit other limits. At some point you’ll run the system out of mbufs. However, I think you’ll hit the NECP limit first [1]. That isn’t a simple count, but dependent on resource usage. It usually kicks in around 500-ish active flows.
This NECP limit applies to NW flows as well as sockets.
The symptoms of hitting the NECP limit is that things fail with otherwise hard to explain ENOSPC
errors.
Taking a step back, if your goal is to run tens of thousands of network flows in a single process, I doubt you’ll be able to achieve that on Apple platforms. If that’s important to you, I recommend that you start by creating some prototypes. Make sure to:
-
Test that the flows work, not just that you can open them.
-
Test on all the platforms you’re targeting. You might, for example, see different results on iOS and macOS.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] I discuss NECP in A Peek Behind the NECP Curtain, but I don’t go into details about its limits.