Network UDP sample client/server code

May I have the simplest iOS14 code using Network Framework to setup an UDP Listener ?
Sending a message works but not receiving
Should I have to put the listener in background ?
Thanks
Take a look at the sample for Building a Custom Peer-to-Peer Protocol as this has a sample for NWListener. You will need to retrofit this class to use NWProtocolUDP, but that should be straight forward. Let me know if you have questions.


Code Block swift
let udpOptions = NWProtocolUDP.Options()
let params = NWParameters(dtls: .init(), udp: udpOptions)
let listener = try NWListener(using: params)


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Network UDP sample client/server code
 
 
Q