"Multipeer Connectivity" only available in iOS.
Correct.
Well, it’s better to say that it’s only available on Apple platforms [1].
Also, while Multipeer Connectivity has its place, in many cases it’s the wrong choice. You wrote:
Basically, a server publishes his service over bonjour and the clients
connected to the same wifi can discover his service
This asymmetric design is a poor match for Multipeer Connectivity and is better served by an implementation that uses Bonjour and our standard TCP/IP APIs.
I am implementing an iPhone/iPad and mac app that allows users to send
each other messages using the bonjour protocol.
Just to clarify, Bonjour is not a protocol. Rather, it’s a marketing term for a number of different protocols:
These protocols let you advertise and discover services but they do not you communicate with those services. For that you’ll need a standard TCP/IP API.
I don't know how can I get list of connected Devices in network
Bonjour does not work in terms of devices but rather in terms of services. For example, you don’t browse for devices and then ask each device what services it’s running. Rather, you browse for services directly.
Our general advice on this front is you use Network framework for this sort of thing. It includes well-integrated support for both Bonjour and TCP (or UDP). Specifically:
-
Use NWListener
to listen for incoming connections. Set the service
to enable Bonjour advertisement.
-
Use NWBrowser
to browse for services.
-
Use NWConnection
to connect to a service.
This gives you a TCP connection between your client and server.
The above is available on all Apple platforms [1]. Non-Apple platforms also support this model, but their Bonjour APIs aren’t integrated, that is, they offer separate Bonjour and TCP/IP APIs and you have to do the integration yourself.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Except watchOS, where the story is more complex.