Which Apple Networking Api to use for UDP multicasting and unicasting?

New to iOS development and networks in general. Developing a game-show-type app where a 'host' device needs to multicast to 'contestant' devices. The contestant devices also need to be able to respond. Very little information is actually being passed along but speed does matter hence the use of UDP. I've been researching some of the commonly used networking api's for apple devices: network.framework, CocoaAsyncSocket, Multipeer-Connectivity, BSD sockets, etc. Overall, I'm leaning towards just using the high-level network.framework but the lack of examples and resources is making the decision difficult. Any advice would be appreciated.

1 Like

Some years ago I made a very simple countdown app for iPad that broadcasted a message to local network when a timer fired. Did this using UDP, implemented with swift-nio. That worked well in that scenario.

The tests included in swift-nio test also multicast broadcasting, giving a sample for you on how to use it. Since not having experience in the other APIs you listed, cannot recommend anything for your use case.

1 Like

I'm familiar with three out of four mentioned networking technologies – highly recommending Network.framework (introducing network framework session with UDP sample at 0:22:12 – 0:32:32).

1 Like

Which Apple Networking Api to use for UDP multicasting and unicasting?

We just published a technote that addresses that exact question: TN3151 Choosing the right networking API.

If you have follow-up questions, I encourage you to start a thread over on Apple Developer Forums, because this is very specific to Apple platforms. Tag it with Network so that I see it.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

4 Likes

That link goes to TN3111, it should be TN3151: Choosing the right networking API | Apple Developer Documentation
:slight_smile:

2 Likes

D’oh! That was a bug in my hot key. I’ve fixed it now. Thanks for the heads up.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple