How to send a UDP message to all link local IPv6 nodes using the Network framework?

When I try to setup a connection, it changes from `waiting(POSIXErrorCode: Network is down)` to preparing state. But it never goes into the ready state.


import Network
import Dispatch

let connection = NWConnection(host: .ipv6(.linkLocalNodes), port: 9898, using: .udp)

connection.stateUpdateHandler = { state in print(state) }
connection.start(queue: DispatchQueue(label: "UDP"))


I found out that this is because there is no interface specified. Because when I setup a connection to

.ipv6(IPv6Address("ff02::1%en4")!)

it does go into the ready state. But then the interface names don't always stay the same. So how should I figure out all the available interface names? Or is there another way I can send a multicast message on all the supported interfaces?

Accepted Reply

Network framework is not currently set up to deal with broadcasts or multicasts. Until that limitation in lifted [1], you should continue to use BSD Sockets for such tasks.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] Which will require new API, and there’s no sign of this being added in 10.15 beta, so it could be a while before we get it.

Replies

Network framework is not currently set up to deal with broadcasts or multicasts. Until that limitation in lifted [1], you should continue to use BSD Sockets for such tasks.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] Which will require new API, and there’s no sign of this being added in 10.15 beta, so it could be a while before we get it.