Network framework: creating multiple listeners with the same port number?

I am trying to have multiple applications listen to the same port but from different local IP addresses but it looks like it doesn't work.

Here is my code:

localEndPoint = nw_endpoint_create_host(ip1, port1234) nw_parameters_set_local_endpoint(params, localEndPoint); ... nw_listener_create(params) ...

So application 1 will use ip1 and application 2 a different local address (ip2) to listen from. When I do that, the second app launched always fails to start the listener with an "address already in use" error.

I thought it was possible, but I am obviously wrong...

Any insight anyone ?

Thanks !

Daniel

Are these IP addresses on the same interface, aka IP aliasing? Or are you trying to run two listeners on two separate interfaces?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Same interface...

Thank you !

Daniel

Same interface...

OK.

We definitely want that to work. If it’s not working, please file a bug about that, then post your bug number, just for the record.

An alternative way to achieve this goal is to have a single listener and then differentiate incoming connections based on their local endpoint.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Just so you know, we also tried with different physical interfaces and it is the same issue. The problem with your suggestion is that these are in different instances of our application (these are video player applications and we need to keep them separate for safety reasons). So they are separate processes. We cannot use different port numbers as the controlling hardware can only talk to a specific port. Could it be the issue that the processes are different ? I just want to make sure I file my bug report correctly and point it in the right direction...

Thank you !

Daniel

Just so you know, we also tried with different physical interfaces and it is the same issue.

Interesting. Please make sure you include that factoid in your eventual bug report.

So they are separate processes.

Well, that’s not the answer I was expecting (-:

Could it be the issue that the processes are different?

It’s possible. The user space networking stack complicates this stuff considerably.

However, this is easy to test: Create a test app that does this in a single process and see how it behaves.

Oh, and what platform is this on? (It sounds like the Mac but I wast want to be sure.) And what version of that?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes, macOS Ventura, latest developer release. Also tried on Monterey, same thing. But since I now know it should work, I will submit the bug report and add its number here.

Thank you Quinn, your help is much appreciated !

Daniel

Here we go: the Feedback Assistant report # is 11453147. I included a sample project to demonstrate it inside a single app (same problem as with different apps).

Thanks !

Daniel

Network framework: creating multiple listeners with the same port number?
 
 
Q