Apple Bonjour: Let's Talk!

squallstar 1,508 views 114 slides May 25, 2012
Slide 1
Slide 1 of 186
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99
Slide 100
100
Slide 101
101
Slide 102
102
Slide 103
103
Slide 104
104
Slide 105
105
Slide 106
106
Slide 107
107
Slide 108
108
Slide 109
109
Slide 110
110
Slide 111
111
Slide 112
112
Slide 113
113
Slide 114
114
Slide 115
115
Slide 116
116
Slide 117
117
Slide 118
118
Slide 119
119
Slide 120
120
Slide 121
121
Slide 122
122
Slide 123
123
Slide 124
124
Slide 125
125
Slide 126
126
Slide 127
127
Slide 128
128
Slide 129
129
Slide 130
130
Slide 131
131
Slide 132
132
Slide 133
133
Slide 134
134
Slide 135
135
Slide 136
136
Slide 137
137
Slide 138
138
Slide 139
139
Slide 140
140
Slide 141
141
Slide 142
142
Slide 143
143
Slide 144
144
Slide 145
145
Slide 146
146
Slide 147
147
Slide 148
148
Slide 149
149
Slide 150
150
Slide 151
151
Slide 152
152
Slide 153
153
Slide 154
154
Slide 155
155
Slide 156
156
Slide 157
157
Slide 158
158
Slide 159
159
Slide 160
160
Slide 161
161
Slide 162
162
Slide 163
163
Slide 164
164
Slide 165
165
Slide 166
166
Slide 167
167
Slide 168
168
Slide 169
169
Slide 170
170
Slide 171
171
Slide 172
172
Slide 173
173
Slide 174
174
Slide 175
175
Slide 176
176
Slide 177
177
Slide 178
178
Slide 179
179
Slide 180
180
Slide 181
181
Slide 182
182
Slide 183
183
Slide 184
184
Slide 185
185
Slide 186
186

About This Presentation

"Bonjour" è ben più di un formale saluto in francese. :) Molti programmatori lo usano durante il proprio lavoro ma pochissimi lo conoscono veramente. Non stiamo ovviamente parlando della lingua francese, ma di "Bonjour", il protocollo di comunicazione che da anni viene utilizza...


Slide Content

Nicholas Valbusa - @squallstar
Intesys Web Agency APPLE BONJOUR,
LET’S TALK!
Thursday, May 24, 12

Thursday, May 24, 12

Few words about me
Thursday, May 24, 12

Nicholas Valbusa
@squallstar
Few words about me
Thursday, May 24, 12

Nicholas Valbusa
@squallstar
Few words about me
Web Developer since 2004
Thursday, May 24, 12

Nicholas Valbusa
@squallstar
Few words about me
Mobile Developer since 2010
Web Developer since 2004
Thursday, May 24, 12

Nicholas Valbusa
@squallstar
Few words about me
Mobile Developer since 2010
WHYMCA 2011: Webkit meets Native development
Web Developer since 2004
Thursday, May 24, 12

Thursday, May 24, 12

Intesys è una Web Agency Innovativa
nata nel 1995 a Verona
Thursday, May 24, 12

Intesys è una Web Agency Innovativa
nata nel 1995 a Verona
Un team di 90 specialisti divisi in 4 aree
Thursday, May 24, 12

Intesys è una Web Agency Innovativa
nata nel 1995 a Verona
Un team di 90 specialisti divisi in 4 aree
Thursday, May 24, 12

We’ll talk about
Thursday, May 24, 12

We’ll talk about
Thursday, May 24, 12

We’ll talk about
Thursday, May 24, 12

•TCP/IP
We’ll talk about
Thursday, May 24, 12

•TCP/IP
•Apple Bonjour, uPNP
We’ll talk about
Thursday, May 24, 12

•TCP/IP
•Apple Bonjour, uPNP
•Socket, Stream, Buffers
We’ll talk about
Thursday, May 24, 12

•TCP/IP
•Apple Bonjour, uPNP
•Socket, Stream, Buffers
•Create and publish a server
We’ll talk about
Thursday, May 24, 12

•TCP/IP
•Apple Bonjour, uPNP
•Socket, Stream, Buffers
•Create and publish a server
•Join a server
We’ll talk about
Thursday, May 24, 12

•TCP/IP
•Apple Bonjour, uPNP
•Socket, Stream, Buffers
•Create and publish a server
•Join a server
•Network messages
We’ll talk about
Thursday, May 24, 12

•TCP/IP
•Apple Bonjour, uPNP
•Socket, Stream, Buffers
•Create and publish a server
•Join a server
•Network messages
•Other...
We’ll talk about
Thursday, May 24, 12

We’ll see
Thursday, May 24, 12

We’ll see
•A screencast native application
Thursday, May 24, 12

We’ll see
•A screencast native application
•Something like chats
Thursday, May 24, 12

We’ll see
•A screencast native application
•Something like chats
•Where server can send images and other things
Thursday, May 24, 12

We’ll see
•A screencast native application
•Something like chats
•Where server can send images and other things
Follow the talk from your iPad using the same app
that we’re going to make
iCast
Thursday, May 24, 12

iCast
Thursday, May 24, 12

iCast
Thursday, May 24, 12

iCast
Thursday, May 24, 12

Thursday, May 24, 12

“Once upon a time”
Thursday, May 24, 12

“Once upon a time”
Apple Talk
Thursday, May 24, 12

“Once upon a time”
•Protocollo usato nelle reti Macintosh
Apple Talk
Thursday, May 24, 12

“Once upon a time”
•Protocollo usato nelle reti Macintosh
•Condivisione di file e stampanti
Apple Talk
Thursday, May 24, 12

“Once upon a time”
•Protocollo usato nelle reti Macintosh
•Condivisione di file e stampanti
•Uno dei primi sistemi plug-n-play
Apple Talk
Thursday, May 24, 12

Thursday, May 24, 12

“things changes”
Thursday, May 24, 12

TCP/IP
“things changes”
Thursday, May 24, 12

TCP/IP
•Negli anni novanta, con la diffusione del TCP/IP
Apple dismesse AppleTalk
“things changes”
Thursday, May 24, 12

TCP/IP
•Negli anni novanta, con la diffusione del TCP/IP
Apple dismesse AppleTalk
•Finalmente i Mac potevano connettersi con
altri sistemi operativi
“things changes”
Thursday, May 24, 12

Thursday, May 24, 12

Zeroconf
DHCPDNS
Thursday, May 24, 12

Zeroconf
DHCPDNS
“A set of techniques that automatically
creates a usable IP network without manual
operator intervention”
Thursday, May 24, 12

Thursday, May 24, 12

Bonjour
Thursday, May 24, 12

Bonjour
L’implementazione Apple
di “Zero configuration network”
Thursday, May 24, 12

Bonjour
L’implementazione Apple
di “Zero configuration network”
“It just works”
Thursday, May 24, 12

Bonjour
•mDNS + DNS Service discovery
L’implementazione Apple
di “Zero configuration network”
“It just works”
Thursday, May 24, 12

Bonjour
•mDNS + DNS Service discovery
•Address assignment
L’implementazione Apple
di “Zero configuration network”
“It just works”
Thursday, May 24, 12

Bonjour
•mDNS + DNS Service discovery
•Address assignment
•Name resolution
L’implementazione Apple
di “Zero configuration network”
“It just works”
Thursday, May 24, 12

Bonjour
Thursday, May 24, 12

•Built-in con OSX e iOS.
Bonjour
Thursday, May 24, 12

•Built-in con OSX e iOS.
•Installabile su Windows
Bonjour
Thursday, May 24, 12

•Built-in con OSX e iOS.
•Installabile su Windows
•Incluso in Safari e iTunes.
Bonjour
Thursday, May 24, 12

•Built-in con OSX e iOS.
•Installabile su Windows
•Incluso in Safari e iTunes.
•Incluso nella Creative Suite 3 di Adobe
Bonjour
Thursday, May 24, 12

Thursday, May 24, 12

Who uses it
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
•iChat, Skype, Adium
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
•iChat, Skype, Adium
•Adobe Creative Suite 3+
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
•iChat, Skype, Adium
•Adobe Creative Suite 3+
•Things, Omnifocus
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
•iChat, Skype, Adium
•Adobe Creative Suite 3+
•Things, Omnifocus
•Cyberduck, Coda, SubEthaEdit
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
•iChat, Skype, Adium
•Adobe Creative Suite 3+
•Things, Omnifocus
•Cyberduck, Coda, SubEthaEdit
•PostgreSQL
Thursday, May 24, 12

Who uses it
•iTunes finds shared music
•iPhotos finds shared photos
•iChat, Skype, Adium
•Adobe Creative Suite 3+
•Things, Omnifocus
•Cyberduck, Coda, SubEthaEdit
•PostgreSQL
•All uPNP-enabled devices
Thursday, May 24, 12

Thursday, May 24, 12

Who can also use it
Thursday, May 24, 12

Who can also use it
Thursday, May 24, 12

Using “jmDNS”, a Java implementation
of multi-cast DNS for LAN service registration/discovery.
Who can also use it
Thursday, May 24, 12

Thursday, May 24, 12

uPNP
Universal plug-n-play
Thursday, May 24, 12

uPNP
•It’s just another implementation of Zeroconf
Universal plug-n-play
Thursday, May 24, 12

uPNP
•It’s just another implementation of Zeroconf
•Media servers, Consoles, DLNA servers...
Universal plug-n-play
Thursday, May 24, 12

uPNP
•It’s just another implementation of Zeroconf
•Media servers, Consoles, DLNA servers...
•No authentication
Universal plug-n-play
Thursday, May 24, 12

uPNP
•It’s just another implementation of Zeroconf
•Media servers, Consoles, DLNA servers...
•No authentication
•No mDNS
Universal plug-n-play
Thursday, May 24, 12

Thursday, May 24, 12

Bonjour: Service Publication
Thursday, May 24, 12

Bonjour: Service Publication
Thursday, May 24, 12

Thursday, May 24, 12

Bonjour: Service Publication
Thursday, May 24, 12

Bonjour: Service Publication
Thursday, May 24, 12

Thursday, May 24, 12

Bonjour: Query for services
Thursday, May 24, 12

Bonjour: Query for services
Thursday, May 24, 12

Thursday, May 24, 12

Bonjour: Connect
Thursday, May 24, 12

Bonjour: Connect
Thursday, May 24, 12

Thursday, May 24, 12

Sockets vs Streams
Thursday, May 24, 12

Sockets vs Streams
•Socket: unique communication
endpoint on the network
Thursday, May 24, 12

Sockets vs Streams
•Socket: unique communication
endpoint on the network
•Stream: one-way channel through
which data is transmitted serially
Thursday, May 24, 12

Thursday, May 24, 12

We will use
Thursday, May 24, 12

We will use
•Stream sockets that are paired up
to allow our app to send data over
network using TCP/IP
Thursday, May 24, 12

We will use
•Stream sockets that are paired up
to allow our app to send data over
network using TCP/IP
•Asynchronous, non-blocking
operations
Thursday, May 24, 12

Thursday, May 24, 12

3 Networking Classes
Thursday, May 24, 12

3 Networking Classes
Server class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
Server class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
Connection class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
•Resolves Bonjour Services
Connection class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
•Resolves Bonjour Services
•Establishes connections to other servers
Connection class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
•Resolves Bonjour Services
•Establishes connections to other servers
•Exchanges data via socket streams
Connection class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
•Resolves Bonjour Services
•Establishes connections to other servers
•Exchanges data via socket streams
Connection class:
Server Browser class:
Thursday, May 24, 12

3 Networking Classes
•Creates a server
•Announces the server via Bonjour
Server class:
•Resolves Bonjour Services
•Establishes connections to other servers
•Exchanges data via socket streams
Connection class:
•Browses for other servers via Bonjour
Server Browser class:
Thursday, May 24, 12

Thursday, May 24, 12

Application layers
Thursday, May 24, 12

Application layers
Thursday, May 24, 12

Application layers
Thursday, May 24, 12

Application layers
Thursday, May 24, 12

Thursday, May 24, 12

Down the Connection class
Thursday, May 24, 12

Down the Connection class
2 stream sockets (one for writing, one for reading)
2 data buffers (one for each socket stream)
Thursday, May 24, 12

Thursday, May 24, 12

Network messages
Thursday, May 24, 12

Network messages
How do we separate network messages from one another?
Thursday, May 24, 12

Network messages
How do we separate network messages from one another?
3 different ways:
Thursday, May 24, 12

Network messages
How do we separate network messages from one another?
1) Make all messages have the same length
3 different ways:
Thursday, May 24, 12

Network messages
How do we separate network messages from one another?
1) Make all messages have the same length
2) Append a marker to each message
3 different ways:
Thursday, May 24, 12

Network messages
How do we separate network messages from one another?
1) Make all messages have the same length
2) Append a marker to each message
3) Send some kind of header with some info about how long the
message is
3 different ways:
Thursday, May 24, 12

Network messages
How do we separate network messages from one another?
1) Make all messages have the same length
2) Append a marker to each message
3) Send some kind of header with some info about how long the
message is
3 different ways:
Thursday, May 24, 12

Thursday, May 24, 12

3) Send some kind of header...
Thursday, May 24, 12

Writing messages
3) Send some kind of header...
Thursday, May 24, 12

Writing messages
•Convert an object into a byte array and measure its length
3) Send some kind of header...
Thursday, May 24, 12

Writing messages
•Convert an object into a byte array and measure its length
•Write the integer (4 bytes) that represents the length of our byte
array to the stream
3) Send some kind of header...
Thursday, May 24, 12

Writing messages
•Convert an object into a byte array and measure its length
•Write the integer (4 bytes) that represents the length of our byte
array to the stream
•Write the actual byte array to the stream
3) Send some kind of header...
Thursday, May 24, 12

Reading messages
Thursday, May 24, 12

Reading messages
•Read first 4 bytes and interpret those as an integer called “x”
Thursday, May 24, 12

Reading messages
•Read first 4 bytes and interpret those as an integer called “x”
•Read “x” number of bytes.
(stop when enough data has been received)
Thursday, May 24, 12

Reading messages
•Read first 4 bytes and interpret those as an integer called “x”
•Read “x” number of bytes.
(stop when enough data has been received)
•Turn received sequence of bytes back into an object.
Thursday, May 24, 12

Thursday, May 24, 12

It’s time!
Thursday, May 24, 12

Thursday, May 24, 12

Frameworks
Thursday, May 24, 12

•Low level: BSD socket lib
Frameworks
Thursday, May 24, 12

•Low level: BSD socket lib
Frameworks
Thursday, May 24, 12

•Low level: BSD socket lib
Frameworks
•High level: CFNetwork
Thursday, May 24, 12

•Low level: BSD socket lib
Frameworks
•High level: CFNetwork
•Bonjour iOS API: NSNetServices,
CFNetServices
Thursday, May 24, 12

Thursday, May 24, 12

Creating a server
Thursday, May 24, 12

Creating a server
We first create a stream
socket that will listen for
connections
Thursday, May 24, 12

Creating a server
We first create a stream
socket that will listen for
connections
CFSocketRef listeningSocket;
Thursday, May 24, 12

Creating a server
We first create a stream
socket that will listen for
connections
CFSocketRef listeningSocket;
using port number 0
Thursday, May 24, 12

Creating a server
We first create a stream
socket that will listen for
connections
CFSocketRef listeningSocket;
using port number 0
zero???? O_o
Thursday, May 24, 12

Thursday, May 24, 12

Let’s publish the service
Thursday, May 24, 12

Let’s publish the service
Thursday, May 24, 12

Thursday, May 24, 12

Services/Servers Browser
Thursday, May 24, 12

Services/Servers Browser
Thursday, May 24, 12

Thursday, May 24, 12

Found!
Thursday, May 24, 12

Found!
Thursday, May 24, 12

Thursday, May 24, 12

Displaying servers list
Thursday, May 24, 12

Displaying servers list
Thursday, May 24, 12

Thursday, May 24, 12

Please let me join
Thursday, May 24, 12

Please let me join
Thursday, May 24, 12

Please let me join
Thursday, May 24, 12

Please let me join
Thursday, May 24, 12

Please let me join
Thursday, May 24, 12

Thursday, May 24, 12

The server receives the “request”
Thursday, May 24, 12

The server receives the “request”
Thursday, May 24, 12

Thursday, May 24, 12

The server welcomes you
Thursday, May 24, 12

The server welcomes you
Thursday, May 24, 12

The server welcomes you
Thursday, May 24, 12

Thursday, May 24, 12

The client receives the stream
Thursday, May 24, 12

The client receives the stream
Thursday, May 24, 12

Thursday, May 24, 12

Recap
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
•Application layers, Socket, Stream, Buffers
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
•Application layers, Socket, Stream, Buffers
•Write/Read Network messages
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
•Application layers, Socket, Stream, Buffers
•Write/Read Network messages
•Create and publish a server
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
•Application layers, Socket, Stream, Buffers
•Write/Read Network messages
•Create and publish a server
•Join a server
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
•Application layers, Socket, Stream, Buffers
•Write/Read Network messages
•Create and publish a server
•Join a server
•Interaction between the client and the server
Thursday, May 24, 12

Recap
•Apple Talk, TCP/IP
•Bonjour flow cycle, uPNP
•Application layers, Socket, Stream, Buffers
•Write/Read Network messages
•Create and publish a server
•Join a server
•Interaction between the client and the server
•One more thing: server broadcasts messages to connected clients
Thursday, May 24, 12

Thursday, May 24, 12

Any questions?
Thank you.
Nicholas Valbusa
@squallstar
Intesys - @Intesys_IT - www.intesys.it
Thursday, May 24, 12