Hi! I have to say I'm not experienced with network programming. Meanwhile, I'm happy my macOs app is doing mostly what it should with Network framework.
What I noticed though is that, observing with DNS-SD, all other Bonjour Services on my system show the domain name
"Felixs-iMac.local"
whereas my app has something like
c0d52654-4459-4373-a42d-778805c5107a.local
with the string before .local
changing on each run.
I also noticed that the third party app that I connect my app to locally is not "remembering" my app after restarting. I can set manually "Remote Address" in that app to localhost
or 127.0.0.1
and it reconnects next time.
I wonder if this is related.
How can I have my listener show up with a persitent host/domain name (not sure with terminology here..) so other apps can re-connect?
Here's my code for the listener:
// advertise Bonjour
let udpOption = NWProtocolUDP.Options()
let params = NWParameters(dtls: nil, udp: udpOption)
if bonjour { params.includePeerToPeer = true }
// create the listener
listener = try! NWListener(using: params, on: 9001)
// Bonjour service
if bonjour { listener?.service = NWListener.Service(name: "ControlPilot", type: "_osc._udp", domain: nil, txtRecord: nil)
}