Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Zero Configuration

Zero Configuration

Zero Configuration on Apple Platform

Yuji Taniguchi

August 20, 2018
Tweet

More Decks by Yuji Taniguchi

Other Decks in Technology

Transcript

  1. Zeroconf • Avahi (Linux / BSD) • Bonjour • Windows

    CE 5.0 (LLMNR) • UPnP • AirPlay / AirPrint • DLNA …
  2. AppleTalk • 1984 • Published phase 2 1989 • Internet(TCP/IP)

    • Rendezvous on Mac OS X Jaguar(v10.2) 2002 • Bonjour on Mac OS X Tiger(v10.4) 2005 • Deleted from Mac OS X Snow Leopard(v10.6) 2009
  3. Server let domain = "local." let type = “_awesome._tcp." let

    name = "Awesome Service" let port: Int32 = 10000
  4. Server let domain = "local." let type = “_awesome._tcp." let

    name = "Awesome Service" let service = NetService(domain: domain, type: type, name: name, port: port) let port: Int32 = 10000
  5. Server let domain = "local." let type = “_awesome._tcp.” let

    name = "Awesome Service" service.publish() let service = NetService(domain: domain, type: type, name: name, port: port) let port: Int32 = 10000
  6. Client browser.searchForServices(ofType: type, inDomain: domain) func netServiceBrowser(_ browser: NetServiceBrowser, didFind

    service: NetService, moreComing: Bool) let domain = "local." let type = “_awesome._tcp."
  7. Client browser.delegate = self browser.searchForServices(ofType: type, inDomain: domain) extension ViewController:

    NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) { // do something... } }
  8. Client extension ViewController: NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind

    service: NetService, moreComing: Bool) { service.resolve(withTimeout: 10.0) } }
  9. Client extension ViewController: NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind

    service: NetService, moreComing: Bool) { service.resolve(withTimeout: 10.0) } } func netServiceDidResolveAddress(_ sender: NetService)
  10. Client extension ViewController: NetServiceDelegate { func netServiceDidResolveAddress(_ sender: NetService) {

    // do something... } } service.resolve(withTimeout: 10.0) service.delegate = self
  11. Command $ dns-sd -B <Type> $ dns-sd -L <Service Name>

    <Type> <Domain> $ dns-sd -G <protocol> <Hostname> $ dns-sd -H Browsing Resolving a service instance Getting IP Address Help
  12. Command $ dns-sd -B _printer._tcp Browsing a printer service Browsing

    for _printer._tcp DATE: ---Mon 20 Aug 2018--- 3:21:58.151 ...STARTING... Timestamp A/R Flags if Domain Service Type Instance Name 3:21:58.151 Add 2 8 local. _printer._tcp. Printer Service
  13. Network.framework let name = "Awesome Service" let type = "_awesome._tcp."

    let domain = "local." let parameters = NWParameters.tcp let port = NWEndpoint.Port(integerLiteral: 10000) listener.service = NWListener.Service(name: name, type: type, domain: domain) guard let listener = try? NWListener(using: parameters, on: port) else { fatalError("Listener can't be initialized") }