Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Zeroconf on iOS
Search
Yuji Taniguchi
August 27, 2018
1.4k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Zeroconf on iOS
About overview about the Bonjour.
Yuji Taniguchi
August 27, 2018
Transcript
54 slides
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
More Decks by Yuji Taniguchi
See All by Yuji Taniguchi
Zero Configuration
natpenguin
1
270
The ownership in iOS
natpenguin
0
400
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
570
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
680
Six Lessons from altMBA
skipperchong
29
4.6k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
360
Into the Great Unknown - MozCon
thekraken
41
2.8k
Darren the Foodie - Storyboard
khoart
PRO
5
4.1k
Designing for humans not robots
tammielis
254
26k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
610
Optimizing for Happiness
mojombo
378
72k
WCS-LA-2024
lcolladotor
0
1k