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

**URL:** <https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586>\
**Category:** Using Swift\
**Tags:** network, api\
**Created:** [June 15, 2023, 2:12am UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586 "2023-06-15T02:12:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis-ay](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/luis-ay/32/30397_2.png) [@luis-ay](https://forums.swift.org/u/luis-ay)\
**Post date:** [June 15, 2023, 2:12am UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586/1 "2023-06-15T02:12:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andreas66](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andreas66/32/19882_2.png) [@andreas66](https://forums.swift.org/u/andreas66)\
**Post date:** [June 15, 2023, 6:30am UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586/2 "2023-06-15T06:30:55Z")

</div>

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](https://github.com/apple/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.

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [June 15, 2023, 8:42am UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586/3 "2023-06-15T08:42:34Z")

</div>

I'm familiar with three out of four mentioned networking technologies – highly recommending Network.framework ([introducing network framework](https://devstreaming-cdn.apple.com/videos/wwdc/2018/715o2fzpdzzzf5f0/715/715_hd_introducing_networkframework_a_modern_alternative_to_sockets.mp4) session with UDP sample at 0:22:12 – 0:32:32).

---

<div class="post-metadata">

**Author:** ![eskimo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/eskimo/32/13558_2.png) [@eskimo](https://forums.swift.org/u/eskimo)\
**Post date:** [June 15, 2023, 9:18am UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586/4 "2023-06-15T09:18:05Z")

</div>

> 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](https://developer.apple.com/documentation/technotes/tn3151-choosing-the-right-networking-api).

If you have follow-up questions, I encourage you to start a thread over on [Apple Developer Forums](https://developer.apple.com/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

---

<div class="post-metadata">

**Author:** ![Martin](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Martin](https://forums.swift.org/u/Martin)\
**Post date:** [June 15, 2023, 11:01am UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586/5 "2023-06-15T11:01:05Z")

</div>

> [@eskimo](#):
>
> We just published a technote that addresses that exact question: TN3151 [Choosing the right networking API](https://developer.apple.com/documentation/technotes/tn3111-ios-wifi-api-overview).

That link goes to TN3111, it should be [TN3151: Choosing the right networking API | Apple Developer Documentation](https://developer.apple.com/documentation/technotes/tn3151-choosing-the-right-networking-api)  
🙂

---

<div class="post-metadata">

**Author:** ![eskimo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/eskimo/32/13558_2.png) [@eskimo](https://forums.swift.org/u/eskimo)\
**Post date:** [June 15, 2023, 12:51pm UTC](https://forums.swift.org/t/which-apple-networking-api-to-use-for-udp-multicasting-and-unicasting/65586/6 "2023-06-15T12:51:44Z")

</div>

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
