I am doing a simple bonjour broadcast using NSNetServices. Everything is working great when I start and stop the bonjour sharing at application launch/quit. However if I turn off bonjour using the stop method call, my app still appears to be broadcasting a dead service even after the netServiceDidStop: delegate message gets called, which prevents restarting of the service until after a relaunch of the app. Apple's documentation makes it look very straightforward, just publish or stop as needed... Am I missing somet开发者_如何转开发hing?
It seems that sometimes services are shown even when they are no longer available.
From Apple documentation:
Because failing to show a valid service is a bigger problem for the user than showing a stale service, Bonjour deliberately errs on the side of assuming that a service is still available.
.
.
although Bonjour generally discovers new services within a few seconds, if a service goes away, the disappearance of the service may not be discovered until your app tries to connect to it and gets no response.
You should not assume that just because the Bonjour APIs report a discovered service, the service is guaranteed to be available when the software tries to access it.
Connecting to and Monitoring Network Services: When resolving fails
精彩评论