iOS使用DNSServiceBrowse和DNSServiceBrowse在服务和客户端之间传递消息

时间:2012-10-18 21:42:20

标签: ios bluetooth multiplayer nsnetservice

我正在尝试与iPhone / iPad设备进行对话,使用DNSServiceRegister注册设备和DNSServiceBrowse来查找服务并解决。

如何在“客户”和服务之间发送消息? 我可以通过套接字监听服务吗?

2 个答案:

答案 0 :(得分:0)

当您开始浏览设备时,您必须设置一个代理,并且– netServiceBrowser:didFindService:moreComing:您需要“解析”该服务...之后(另一位代理人- (void)netServiceDidResolveAddress:)您可以使用getInputStream:outputStream:获取In / Out套接字。之后你就可以开始沟通了。你可以在https://developer.apple.com/library/ios/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Introduction.htmlhttps://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Streams/Streams.html找到更多信息,还有WiTap示例,它们的功能基本相同。

答案 1 :(得分:0)

感谢您的回复。

这些方法netServiceBrowser:didFindService:moreComing: - (void)netServiceDidResolveAddress :)等,使用NSNetService注册服务很有效。 我的应用程序我使用DNSServiceRegister注册服务,这是一个低级API: https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/dns_discovery_api/Articles/registering.html#//apple_ref/doc/uid/TP40002478-SW1

我可以注册服务,浏览服务并解决,但我不知道在服务方面该怎么做才能收听来自“客户”连接的消息。

相关问题