2

I am trying to implement a conversation with iPhone/iPad devices using DNSServiceRegister to register devices and DNSServiceBrowse to find services and resolve.

How can I send messages between the 'client' and the service? there is any listener that I can put on the service to listen for messages via socket?

4

2 回答 2

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

我能够注册服务,浏览服务并解决,但我不知道在服务端做什么来监听来自连接的“客户端”的消息。

于 2012-10-19T16:08:29.077 回答
0

当您开始浏览设备时,您必须设置一个委托,并且– netServiceBrowser:didFindService:moreComing:您必须在其中“解决”服务......之后(另一个委托- (void)netServiceDidResolveAddress:)您可以使用getInputStream:outputStream:. 之后就可以开始交流了。您可以在这里找到更多信息https://developer.apple.com/library/ios/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Introduction.html或在这里https://developer.apple.com/library/ios/#documentation/ Cocoa/Conceptual/Streams/Streams.html还有一个示例 WiTap,它的作用基本相同。

于 2012-10-18T21:55:11.457 回答