iOS take messages between service and client with DNSServiceBrowse and DNSServiceBrowse

244 Views Asked by At

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?

2

There are 2 best solutions below

0
On

There is a delegate you have to set when you start browsing for devices and there is – netServiceBrowser:didFindService:moreComing: where you have to "resolve" the service ... after that (another delegate with - (void)netServiceDidResolveAddress:) you can get In/Out sockets with getInputStream:outputStream:. after that you can start communication. You can find more here https://developer.apple.com/library/ios/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Introduction.html or here https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Streams/Streams.html there is also example WiTap which doeas basically the same thing.

0
On

Thanks for your reply.

these methods netServiceBrowser:didFindService:moreComing: - (void)netServiceDidResolveAddress:), etc,.. works great using NSNetService to register a service. I my app I am using DNSServiceRegister to register the service, which is a low level API: https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/dns_discovery_api/Articles/registering.html#//apple_ref/doc/uid/TP40002478-SW1

I am able to register the service, browse for the service and resolve, but I don't know what to do on the service side to listen for messages coming from the 'client' connected.