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
Zero Configuration
Search
Yuji Taniguchi
August 20, 2018
Technology
1
170
Zero Configuration
Zero Configuration on Apple Platform
Yuji Taniguchi
August 20, 2018
Tweet
Share
More Decks by Yuji Taniguchi
See All by Yuji Taniguchi
Zeroconf on iOS
natpenguin
2
1.2k
The ownership in iOS
natpenguin
0
340
Other Decks in Technology
See All in Technology
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
880
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
Lexical Analysis
shigashiyama
1
150
The Rise of LLMOps
asei
7
1.7k
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
1.1k
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
120
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
300
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
Featured
See All Featured
What's new in Ruby 2.0
geeforr
343
31k
Practical Orchestrator
shlominoach
186
10k
Building Applications with DynamoDB
mza
90
6.1k
Adopting Sorbet at Scale
ufuk
73
9.1k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
How to Ace a Technical Interview
jacobian
276
23k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
A Modern Web Designer's Workflow
chriscoyier
693
190k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Transcript
Zero Configuration Nagoya iOS meetup Vol. 4
Introduction • Software Engineer at merpay • Twitter : @_natpenguin
• GitHub : natpenguin
Agenda • What is the Zero Configuration? • Zero Configuration
on Apple Platform • Coding on iOS
Zero Configuration Networking (Zeroconf)
Zero Configuration Networking connecting
Zero Configuration Networking connected
Zeroconf • Avahi (Linux / BSD) • Bonjour • Windows
CE 5.0 (LLMNR) • UPnP • AirPlay / AirPrint • DLNA …
Application developer IP Address Domain Don’t need to know
Bonjour
History
AppleTalk
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
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 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 extension ViewController: NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind
service: NetService, moreComing: Bool) { // do something... } }
Client browser.delegate = self browser.searchForServices(ofType: type, inDomain: domain) extension ViewController:
NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) { // do something... } }
Client extension ViewController: NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind
service: NetService, moreComing: Bool) { service.resolve(withTimeout: 10.0) } }
Client extension ViewController: NetServiceBrowserDelegate { func netServiceBrowser(_ browser: NetServiceBrowser, didFind
service: NetService, moreComing: Bool) { service.resolve(withTimeout: 10.0) } } func netServiceDidResolveAddress(_ sender: NetService)
Client extension ViewController: NetServiceDelegate { func netServiceDidResolveAddress(_ sender: NetService) {
// do something... } } service.resolve(withTimeout: 10.0) service.delegate = self
Client more BSD Socket CFSocket NSStream
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") }
Let’s enjoy