Network framework UDP broadcast

I'm running the 10.14 (Mojave) beta with Xcode 10 and trying to use the new Network framework. I'm able to send UDP packets to a normal ipv4 address but when I try to send to the IPv4Address.broadcast address I receive a send completed, error = POSIXErrorCode: Permission denied


In other networking code I have to explicitly enable broadcasts but I can't find any similar option in the new Network framework.


Can the new framework do UDP broadcast? If so, how to enable it?


Thank you

Accepted Reply

Network.framework doesn't currently have support for UDP multicast or broadcast. There are a number of challenges around broadcast that may make it very difficult to use. IPv6 doesn't even have broadcast. If you can use multicast instead you will likely have much better success going forward. If you're interacting with something that requires broadcast, you might try sending to a subnet broadcast. Can you describe your use case a little more?


For any enhancement requests, such as broadcast support in Network.framework, please use https://bugreport.apple.com/. A detailed description of your use case will help. Thank you.

Replies

Network.framework doesn't currently have support for UDP multicast or broadcast. There are a number of challenges around broadcast that may make it very difficult to use. IPv6 doesn't even have broadcast. If you can use multicast instead you will likely have much better success going forward. If you're interacting with something that requires broadcast, you might try sending to a subnet broadcast. Can you describe your use case a little more?


For any enhancement requests, such as broadcast support in Network.framework, please use https://bugreport.apple.com/. A detailed description of your use case will help. Thank you.

Thank you for the update.


The app is a small "tester" that I use to simulate multiple devices on my network. The device I'm simulating is a communications radio (Flex Radio 6500). The radio sends a broadcast every second to alert their client software (SmartSDR) to the presence of a radio. I only own one radio so I wrote a small app (in Swift using CocoaAsyncSockets) to generate broadcast messages to make the client software believe that there are multiple radios available on the network. The existing app works fine, CocoaAsyncSockets allows you to enable Broadcast (I'm only using IPv4). I was hoping to eliminate CocoaAsyncSockets and use the Network framework instead.


You suggested "If you're interacting with something that requires broadcast, you might try sending to a subnet broadcast.", how would I tell the Network framework to do that? Would the client expecting a broadcast see that as equivalent? I've been all through the header / documentation files, if you could point me to a setting that would be helpful.


Unfortunately, I can't change the radio's behavior.


Thanks again