NetworkFramework and UDP Broadcast Mode (2025)

So it seems the NetworkFramework is still not able to support Broastcast Mode am I correct?

As soon as I switch broadcast mode to On in my game I receive console messages instead of receiving data.

nw_path_evaluator_create_flow_inner failed NECP_CLIENT_ACTION_ADD_FLOW (null) evaluator parameters: udp, definite, server, attribution: developer, reuse local address, context: Default Network Context (private), proc: 2702288D-96FB-37DD-8610-A68CC526EA0F, local address: 0.0.0.0:20778
nw_path_evaluator_create_flow_inner NECP_CLIENT_ACTION_ADD_FLOW 1FB68D7E-7C9B-47B2-B6AC-E5710CD9C9CD [17: File exists]
nw_endpoint_flow_setup_channel [C2 192.168.178.221:52716 initial channel-flow (satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, uses wifi)] failed to request add nexus flow
nw_endpoint_flow_failed_with_error [C2 192.168.178.221:52716 initial channel-flow (satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, uses wifi)] already failing, returning
nw_endpoint_handler_create_from_protocol_listener [C2 192.168.178.221:52716 failed channel-flow (satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, uses wifi)] nw_endpoint_flow_pre_attach_protocols
nw_connection_create_from_protocol_on_nw_queue [C2] Failed to create connection from listener
nw_ip_channel_inbox_handle_new_flow nw_connection_create_from_protocol_on_nw_queue failed

I won't be able to receive data which is a real shame, so I guess I am stuck with the lower level code:

 // Enable broadcast
var enableBroadcast: Int32 = 1
 if setsockopt(socketDescriptor, SOL_SOCKET, SO_BROADCAST, &enableBroadcast, socklen_t(MemoryLayout<Int32>.size)) == -1 {
     let errorMessage = String(cString: strerror(errno))
     throw UDPSocketError.cannotEnableBroadcast(errorMessage)
}
Answered by DTS Engineer in 834370022

The exact story with Network framework’s limited UDP support is complex. I actually dug into it recently and the results were worse than I expected. It’s not a path I recommend that you go down.

Do you actually need to use broadcasts? I find a lot of folks reach for broadcasts when they’d be better server by alternatives:

  • Bonjour for service discovery

  • UDP unicasts for time-sensitive traffic

  • Multicasts for the rest

I expand on these concepts in Broadcasts and Multicasts, Hints and Tips.

The only good reason I see for using UDP broadcasts these days is that you have to interoperate with a device whose firmware you can’t change. For everything else, there’s a better path forward.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The exact story with Network framework’s limited UDP support is complex. I actually dug into it recently and the results were worse than I expected. It’s not a path I recommend that you go down.

Do you actually need to use broadcasts? I find a lot of folks reach for broadcasts when they’d be better server by alternatives:

  • Bonjour for service discovery

  • UDP unicasts for time-sensitive traffic

  • Multicasts for the rest

I expand on these concepts in Broadcasts and Multicasts, Hints and Tips.

The only good reason I see for using UDP broadcasts these days is that you have to interoperate with a device whose firmware you can’t change. For everything else, there’s a better path forward.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

NetworkFramework and UDP Broadcast Mode (2025)
 
 
Q