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
Yuji Taniguchi
August 27, 2018
2
1.2k
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
170
The ownership in iOS
natpenguin
0
340
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
How to Ace a Technical Interview
jacobian
276
23k
YesSQL, Process and Tooling at Scale
rocio
170
14k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
110
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Bash Introduction
62gerente
609
210k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Adopting Sorbet at Scale
ufuk
73
9.1k
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