gpt4 book ai didi

cocoa - NSNetServices 在停止方法调用后仍然存在?

转载 作者:行者123 更新时间:2023-12-03 17:25:19 27 4
gpt4 key购买 nike

我正在使用 NSNetServices 进行简单的 bonjour 广播。当我在应用程序启动/退出时启动和停止 bonjour 共享时,一切都运行良好。但是,如果我使用 stop 方法调用关闭 bonjour,即使在调用 netServiceDidStop: 委托(delegate)消息之后,我的应用程序似乎仍然在广播死服务,这会阻止服务重新启动,直到重新启动应用程序后。苹果的文档让它看起来非常简单,只需根据需要发布或停止...我错过了什么吗?

最佳答案

有时,即使服务不再可用,也会显示这些服务。

摘自苹果文档:

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

关于cocoa - NSNetServices 在停止方法调用后仍然存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6949542/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com