iosobjective-cbonjourcfnetworkcfnetworking

How to send data from iphone to bonjour service?


I created an iOS app in objective-c, and this app first browse the local networks. After the app found a bonjour service I would like to read/write data to that computer. I think I should use the CFNetwork framework but which part? What is the simplies way to read/write data from a computer in the same network?


Solution

  • The Bonjour service's main function is to discover other Bonjour enabled device on LAN, it does nothing about read/write the data from a computer. To read/write the data on a computer, you will have to leverage some other network protocols, HTTP is one of them and commonly used.

    Let's say you implement some API interface on HTTP, then you can use the Bonjour to locate the device and establish the communication. For example, if the computer's Bonjour name is mypc._tcp.local., then write data could be done with http://mypc._tcp.local./write/data (depends on your API implementation).

    Apple documentation about Bonjour, Bonjour Overview