Sending and receiving UDP packets from Swift

I would like to be able to send and receive UDP packets from my Swift app. (on iOS 13.0, Xcode 11)
I'm trying to implement a lightweight SSDP discovery service.

I have already implemented this by using my existing C code, and adding a Bridging-Header - but it seems like there should be a more swift-like way to do this?

Is there a way to do UDP sockets native in Swift, or is my bridging header approach the right thing already?

You can use SwiftNIO:

There are examples:

And please check this:


Nice one! Thanks!