I wrote a small Swift program that should send a Hello World!
UDP package to any IPv6 link-local node that’s listening. However, using netcat via nc -l 1234
to listen for the message on port 1234
never receives it. Here’s my code (this class instance is being kept alive inside a SwiftUI view):
@Observable
class NetworkService {
let conn: NWConnection
let monitor: NWPathMonitor
init() {
monitor = NWPathMonitor()
conn = NWConnection(host: .ipv6(IPv6Address("ff02::1%lo0")!), port: 1234, using: .udp)
start()
}
func start() {
conn.send(content: "Hello from Swift!".data(using: .utf8), completion: .idempotent)
conn.start(queue: .main)
print("Done!")
}
}
I’ve tried to send a UDP package to the multicast IPv6 address of link-local nodes, on interface lo0
and expected necat client to receive it.