apple / swift-nio-transport-services

Extensions for SwiftNIO to support Apple platforms as first-class citizens.
https://swiftpackageindex.com/apple/swift-nio-transport-services/main/documentation/niotransportservices
Apache License 2.0
282 stars 71 forks source link

Example for Bounjour service announcement would be useful #131

Closed vvuk closed 2 years ago

vvuk commented 2 years ago

I've got a swift-nio app working, and I wanted to add mDNS-based service discovery. Basically, advertise my service on the port I already have things listening on (or advertise it on a random port, doesn't really matter). I had hoped it would be just a matter of switching to NIOTSEventLoop, NIOTSListenerBootstrap etc., and then setting up a bootstrap.bind(endpoint: .service(...)), but that doesn't seem sufficient (I don't see the service getting advertised).

It would be really handy to have an example for this use case, since it's probably fairly common.

tomerd commented 2 years ago

swift-nio itself does not deal with service discovery, which is intentional given its low level and focused nature. we also have https://github.com/apple/swift-service-discovery which provides the basic building blocks to build upon for such use cases, and there are several folks who implemented concrete SD systems with it on top of things like DNS.

tomerd commented 2 years ago

cc @yim-lee

vvuk commented 2 years ago

Yeah, this is less about the discovery, and more about being able to receive a connection via a service broadcast.

It turns out it was actually as easy as I described above, I just typo'd the service name in my Info.plist declaration! :/

Lukasa commented 2 years ago

Great, seems like this all got addressed.