Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Zeroconf on iOS
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuji Taniguchi
August 27, 2018
2
1.3k
Zeroconf on iOS
About overview about the Bonjour.
Yuji Taniguchi
August 27, 2018
Tweet
Share
More Decks by Yuji Taniguchi
See All by Yuji Taniguchi
Zero Configuration
natpenguin
1
230
The ownership in iOS
natpenguin
0
360
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
63
How to make the Groovebox
asonas
2
1.9k
Site-Speed That Sticks
csswizardry
13
1.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
How to build a perfect <img>
jonoalderson
1
4.9k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
64
Building an army of robots
kneath
306
46k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
820
How GitHub (no longer) Works
holman
316
140k
Mobile First: as difficult as doing things right
swwweet
225
10k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
180
Transcript
Zeroconf on iOS merpay Tech Talk #1
About me • Software Engineer at merpay • Twitter :
@_natpenguin • GitHub : natpenguin
Agenda • What is the Zeroconf? • Coding on iOS
Zeroconf
Zero Configuration Networking Zeroconf
Zeroconf connecting…
Zeroconf connected!
Zeroconf connected! No needed human operation
Zeroconf • To provide IP address • To automatically resolve
the host name • To automatically distribute the host name • To find services
History
AppleTalk
AppleTalk 1984
1984 # $
Protocol AppleTalk Address Resolution Protocol / AppleTalk Address Resolution Protocol
/ Datagram Delivery Protocol /FUXPSL Transport 4FTTJPO 1SFTFOUBUJPO "QQMJDBUJPO Routing Table Maintenance Protocol / AppleTalk Echo Protocol / Name Binding Protocol / AppleTalk Transaction Protocol / AppleTalk Update-Based Routing Protocol AppleTalk Filing Protocol Zone Information Protocol / Printer Access Protocol / AppleTalk Session Protocol / AppleTalk Data Stream Protocol
Problem
Load
Problem on AppleTalk
Problem on AppleTalk
TCP/IP
TCP/IP AppleTalk
AppleTalk
Bonjour
Bonjour • Instead of AppleTalk • Resolved the problem of
performance • Implementation on TCP/IP • AirPrint / AirPlay(AirTunes) • Only local network
Coding
Bonjour API • To provide IP address • To automatically
resolve the host name • To automatically distribute the host name • To find services
Bonjour API • To provide IP address • To automatically
resolve the host name • To automatically distribute the host name • To find services
Coding
Server NetService
Server let domain = "local." let type = "_awesome._tcp." let
name = "Awesome Service" let port: Int32 = 10000
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
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
https://www.iana.org/assignments/ service-names-port-numbers/ service-names-port-numbers.xhtml Document of Type
Client NetServiceBrowser
Client let domain = "local." let type = "_awesome._tcp."
Client let domain = "local." let type = "_awesome._tcp." browser.searchForServices(ofType:
type, inDomain: domain)
Client browser.searchForServices(ofType: type, inDomain: domain) func netServiceBrowser(_ browser: NetServiceBrowser, didFind
service: NetService, moreComing: Bool) let domain = "local." let type = "_awesome._tcp."
Client browser.searchForServices(ofType: type, inDomain: domain) func netServiceBrowser(_ browser: NetServiceBrowser, didFind
service: NetService, moreComing: Bool) let domain = "local." let type = "_awesome._tcp." browser.delegate = self
Client extension ViewController: NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind
service: NetService, moreComing: Bool) { service.resolve(withTimeout: 10.0) } }
Client func netServiceDidResolveAddress(_ sender: NetService) extension ViewController: NetServiceBrowserDelegate { func
netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) { service.resolve(withTimeout: 10.0) } }
Client func netServiceDidResolveAddress(_ sender: NetService) extension ViewController: NetServiceBrowserDelegate { func
netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) { service.delegate = self service.resolve(withTimeout: 10.0) } }
Client more BSD Socket CFSocket NSStream
https://developer.apple.com/ documentation/foundation/ netservice Document of NetService
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
Command $ dns-sd -B _printer._tcp Browsing a printer service
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
iOS12
Network.framework
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") }
Android https://github.com/mannodermaus/ RxBonjour https://github.com/andriydruk/ RxDNSSD https://github.com/HQarroum/ android-mdns
Paradigm Foo Foo
Paradigm Foo Foo Zeroconf
Paradigm
Paradigm Zeroconf
Let’s enjoy