SlideShare a Scribd company logo
1 of 35
Download to read offline
IT’S ZEROCONF
Bonjour Android
Roberto Orgiu
Giuseppe Mariniello
Android Developer
Backend Developer
WHAT IS ZEROCONF?
“ZERO-CONFIGURATION NETWORKING IS A SET OF
TECHNOLOGIES THAT AUTOMATICALLY CREATES A USABLE
COMPUTER NETWORK BASED ON THE INTERNET PROTOCOL
SUITE (TCP/IP) WHEN COMPUTERS OR NETWORK
PERIPHERALS ARE INTERCONNECTED.“
WHAT IS ZEROCONF
WHAT IS ZEROCONF
“IT DOES NOT REQUIRE MANUAL
OPERATOR INTERVENTION OR SPECIAL
CONFIGURATION SERVERS.“
WHERE CAN WE FIND
ZEROCONF?
ALMOST EVERYWHERE
BONJOUR ANDROID, IT’S ZEROCONF
THINK “DIFFERENT”
▸ ZeroConf is a standard
▸ UPnP/DLNA are somehow similar, but different people and ideas
▸ Apple has its own implementation, called Bonjour (once Rendezvous)
▸ On Android, we have very different solutions for using it
APPLE OFTEN REFERS TO ZEROCONF AS
BONJOUR, GIVING THEIR OWN
DEFINITION OF THE CONCEPTS
BONJOUR ANDROID, IT’S ZEROCONF
FUN FACT
Wut? Why do you even…?
BONJOUR ANDROID, IT’S ZEROCONF
HOW DOES IT WORK?
Ehy! I am 192.168.1.50
and I have the service
DroidConService running
on port 56472!
Great! Exactly what I was looking for!
BONJOUR ANDROID, IT’S ZEROCONF
▸ No infrastructure needed
▸ Simplicity over scalability
▸ 4 areas: IP interface configuration, translation between host name and IP
address, IP multicast address allocation, service discovery
▸ Aware of network changes
▸ Still a draft
HOW DOES IT WORK?
BONJOUR ANDROID, IT’S ZEROCONF
▸ Configure netmask
▸ Allocate unique IP address
IP INTERFACE CONFIGURATION
BONJOUR ANDROID, IT’S ZEROCONF
▸ Allows hostnames to be mapped to IP addresses and back
▸ Failure proof with retry mechanism
▸ Conflict detection
TRANSLATION BETWEEN HOST NAME AND IP ADDRESS
BONJOUR ANDROID, IT’S ZEROCONF
IP MULTICAST ADDRESS ALLOCATION
▸ List which of the scopes (local, site-local, link-local) are available
▸ Select a multicast address preventing conflicts
BONJOUR ANDROID, IT’S ZEROCONF
SERVICE DISCOVERY
▸ Service must be discoverable via identifier and/or type
▸ Discovery without the use of a service-specific protocol and should complete in
a timely manner (10s of seconds)
▸ Prompt detection of new services in a timely manner (10s of seconds)
D
R
A
F
T
BONJOUR ANDROID, IT’S ZEROCONF
HOW DOES IT WORK?
▸ Each part must start with _ (underscore)
▸ The second part only allows _tcp or _udp
_ServiceType._TransportProtocolName.
List of common services goo.gl/EXh1g
BONJOUR ANDROID, IT’S ZEROCONF
WHAT ABOUT ANDROID?
▸ API FROM 4.1
▸ JMDNS FOR JAVA
▸ APPLE NATIVE (C++) IMPLEMENTATION
BONJOUR ANDROID, IT’S ZEROCONF
JMDNS FOR JAVA
▸ Easy to implement
▸ Runs on the main thread, unless we specify otherwise
▸ Distributed as JAR or via Maven repo
▸ Long start-up time
▸ Compatible with all the Android versions
BONJOUR ANDROID, IT’S ZEROCONF
WHAT ABOUT ANDROID?
▸ API FROM 4.1
▸ JMDNS FOR JAVA
▸ APPLE NATIVE (C++) IMPLEMENTATION
BONJOUR ANDROID, IT’S ZEROCONF
APPLE NATIVE (C++) IMPLEMENTATION
▸ Ported to Android by Apple
▸ Open-sourced
▸ Needs Android NDK
▸ Few projects come with it already packed in
▸ Short startup time
▸ More complex logic
BONJOUR ANDROID, IT’S ZEROCONF
WHAT ABOUT ANDROID?
▸ API FROM 4.1
▸ JMDNS FOR JAVA
▸ APPLE NATIVE (C++) IMPLEMENTATION
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API
▸ From Android 4.1, custom attributes added with 5.1 (API 21)
▸ Already asynchronous, with return on the main thread
▸ Verbose, but easy to implement
▸ Based on two steps: discovery and resolution
▸ Only one service can be resolved at a time
http://developer.android.com/training/connect-devices-wirelessly/nsd.html
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - SERVER
NsdServiceInfo serviceInfo = new NsdServiceInfo();
serviceInfo.setServiceName("DroidConService");
serviceInfo.setServiceType("_http._tcp.");
serviceInfo.setPort(randomPort);
nsdManager = Context.getSystemService(Context.NSD_SERVICE);
nsdManager.registerService(serviceInfo,
NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
Remember to unregister the service upon app closing!
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class Resolver extends NsdManager.ResolveListener {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
// here we can use our resolved service
}
};
Resolve resolveListener = new Resolve();
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class Resolver extends NsdManager.ResolveListener {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
// here we can use our resolved service
}
};
Resolve resolveListener = new Resolve();
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class SimpleDiscoveryListener extends NsdManager.DiscoveryListener {
@Override public void onDiscoveryStarted(String regType) {}
@Override public void onServiceFound(NsdServiceInfo service) {
if (service.getServiceName().contains(“DroidConService")){
nsdManager.resolveService(service, resolveListener);
}
}
@Override public void onServiceLost(NsdServiceInfo service) {}
@Override public void onDiscoveryStopped(String serviceType) {}
@Override public void onStartDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}
@Override public void onStopDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}};
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
class SimpleDiscoveryListener extends NsdManager.DiscoveryListener {
@Override public void onDiscoveryStarted(String regType) {}
@Override public void onServiceFound(NsdServiceInfo service) {
if (service.getServiceName().contains(“DroidConService")){
nsdManager.resolveService(service, resolveListener);
}
}
@Override public void onServiceLost(NsdServiceInfo service) {}
@Override public void onDiscoveryStopped(String serviceType) {}
@Override public void onStartDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}
@Override public void onStopDiscoveryFailed(String serviceType, int errorCode) {
nsdManager.stopServiceDiscovery(this);
}};
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener();
nsdManager.discoverServices(SERVICE_TYPE,
NsdManager.PROTOCOL_DNS_SD, discoveryListener);
nsdManager.stopServiceDiscovery(discoveryListener);
BONJOUR ANDROID, IT’S ZEROCONF
ANDROID API - CLIENT
SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener();
nsdManager.discoverServices(SERVICE_TYPE,
NsdManager.PROTOCOL_DNS_SD, discoveryListener);
nsdManager.stopServiceDiscovery(discoveryListener);
ARE THERE BETTER
WAYS OF DOING IT?
YES, THERE ARE!
ARE THERE BETTER WAYS OF DOING IT
BONJOUR ANDROID, IT’S ZEROCONF
BETTER WAYS OF DOING IT
▸ better-zeroconf
▸ RxDNSSD
▸ RxBonjour
▸ ZeRxConf
▸ android-mdns
▸ JmDNS
▸ Apple mDNS
▸ Apple mDNS
▸ JmDNS + Android Native APIs
▸ Apple mDNS
DEMO TIME!
Q & A
CHECK THE REPO @ GITHUB.COM/ENNOVA-IT/DROIDCON-DEMO
BONJOUR ANDROID, IT’S ZEROCONF
THANKS FOR WATCHING!

More Related Content

What's hot

Cisco asa dhcp services
Cisco asa dhcp servicesCisco asa dhcp services
Cisco asa dhcp services
IT Tech
 
Network address translations
Network address translations Network address translations
Network address translations
Shahzad shareef
 
Chapter11ccna
Chapter11ccnaChapter11ccna
Chapter11ccna
robertoxe
 

What's hot (20)

Kamailio World 2018: Having fun with new stuff
Kamailio World 2018: Having fun with new stuffKamailio World 2018: Having fun with new stuff
Kamailio World 2018: Having fun with new stuff
 
Otto AI
Otto AIOtto AI
Otto AI
 
Packet Tracer: Nat protocol
Packet Tracer: Nat protocolPacket Tracer: Nat protocol
Packet Tracer: Nat protocol
 
Data communication part 7
Data communication part 7Data communication part 7
Data communication part 7
 
Ipo spaces calling document-v1
Ipo spaces calling document-v1Ipo spaces calling document-v1
Ipo spaces calling document-v1
 
X-Device Service Discovery
X-Device Service DiscoveryX-Device Service Discovery
X-Device Service Discovery
 
Nat
NatNat
Nat
 
NAT Scneario
NAT ScnearioNAT Scneario
NAT Scneario
 
Network Address Translation (NAT)
Network Address Translation (NAT)Network Address Translation (NAT)
Network Address Translation (NAT)
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installations
 
Cisco asa dhcp services
Cisco asa dhcp servicesCisco asa dhcp services
Cisco asa dhcp services
 
Nat pat
Nat patNat pat
Nat pat
 
WebRTC and Janus intro for FOSS Stockholm January 2019
WebRTC and Janus intro for FOSS Stockholm January 2019WebRTC and Janus intro for FOSS Stockholm January 2019
WebRTC and Janus intro for FOSS Stockholm January 2019
 
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatBuild HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
 
Network address translations
Network address translations Network address translations
Network address translations
 
Asterisk Deployments
Asterisk DeploymentsAsterisk Deployments
Asterisk Deployments
 
SWIFT: Tango's Infrastructure For Real-Time Video Call Service
SWIFT: Tango's Infrastructure For Real-Time Video Call ServiceSWIFT: Tango's Infrastructure For Real-Time Video Call Service
SWIFT: Tango's Infrastructure For Real-Time Video Call Service
 
Chapter11ccna
Chapter11ccnaChapter11ccna
Chapter11ccna
 
Static NAT
Static NATStatic NAT
Static NAT
 
NAT (network address translation) & PAT (port address translation)
NAT (network address translation) & PAT (port address translation)NAT (network address translation) & PAT (port address translation)
NAT (network address translation) & PAT (port address translation)
 

Similar to Bonjour Android, it's ZeroConf

Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)
Giacomo Bergami
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONE
Software AG
 

Similar to Bonjour Android, it's ZeroConf (20)

Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020
 
Introduction to Cordova
Introduction to CordovaIntroduction to Cordova
Introduction to Cordova
 
Android
AndroidAndroid
Android
 
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...Connecting with the enterprise - The how and why of connecting to Enterprise ...
Connecting with the enterprise - The how and why of connecting to Enterprise ...
 
React Native
React NativeReact Native
React Native
 
Ionic Hybrid Mobile Application
Ionic Hybrid Mobile ApplicationIonic Hybrid Mobile Application
Ionic Hybrid Mobile Application
 
Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)Android Internals (This is not the droid you’re loking for...)
Android Internals (This is not the droid you’re loking for...)
 
Cross platform mobile apps using .NET
Cross platform mobile apps using .NETCross platform mobile apps using .NET
Cross platform mobile apps using .NET
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
 
Droidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introductionDroidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introduction
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introduction
 
Webinar on Google Android SDK
Webinar on Google Android SDKWebinar on Google Android SDK
Webinar on Google Android SDK
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
 
6-ZeroLab_decentralized_applications-2008.pptx
6-ZeroLab_decentralized_applications-2008.pptx6-ZeroLab_decentralized_applications-2008.pptx
6-ZeroLab_decentralized_applications-2008.pptx
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introduction
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONE
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 
FRIDA 101 Android
FRIDA 101 AndroidFRIDA 101 Android
FRIDA 101 Android
 
Binding android piece by piece
Binding android piece by pieceBinding android piece by piece
Binding android piece by piece
 

Recently uploaded

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Bonjour Android, it's ZeroConf

  • 1. IT’S ZEROCONF Bonjour Android Roberto Orgiu Giuseppe Mariniello Android Developer Backend Developer
  • 3. “ZERO-CONFIGURATION NETWORKING IS A SET OF TECHNOLOGIES THAT AUTOMATICALLY CREATES A USABLE COMPUTER NETWORK BASED ON THE INTERNET PROTOCOL SUITE (TCP/IP) WHEN COMPUTERS OR NETWORK PERIPHERALS ARE INTERCONNECTED.“ WHAT IS ZEROCONF
  • 4. WHAT IS ZEROCONF “IT DOES NOT REQUIRE MANUAL OPERATOR INTERVENTION OR SPECIAL CONFIGURATION SERVERS.“
  • 5. WHERE CAN WE FIND ZEROCONF?
  • 7. BONJOUR ANDROID, IT’S ZEROCONF THINK “DIFFERENT” ▸ ZeroConf is a standard ▸ UPnP/DLNA are somehow similar, but different people and ideas ▸ Apple has its own implementation, called Bonjour (once Rendezvous) ▸ On Android, we have very different solutions for using it
  • 8. APPLE OFTEN REFERS TO ZEROCONF AS BONJOUR, GIVING THEIR OWN DEFINITION OF THE CONCEPTS BONJOUR ANDROID, IT’S ZEROCONF FUN FACT
  • 9. Wut? Why do you even…?
  • 10. BONJOUR ANDROID, IT’S ZEROCONF HOW DOES IT WORK? Ehy! I am 192.168.1.50 and I have the service DroidConService running on port 56472! Great! Exactly what I was looking for!
  • 11. BONJOUR ANDROID, IT’S ZEROCONF ▸ No infrastructure needed ▸ Simplicity over scalability ▸ 4 areas: IP interface configuration, translation between host name and IP address, IP multicast address allocation, service discovery ▸ Aware of network changes ▸ Still a draft HOW DOES IT WORK?
  • 12. BONJOUR ANDROID, IT’S ZEROCONF ▸ Configure netmask ▸ Allocate unique IP address IP INTERFACE CONFIGURATION
  • 13. BONJOUR ANDROID, IT’S ZEROCONF ▸ Allows hostnames to be mapped to IP addresses and back ▸ Failure proof with retry mechanism ▸ Conflict detection TRANSLATION BETWEEN HOST NAME AND IP ADDRESS
  • 14. BONJOUR ANDROID, IT’S ZEROCONF IP MULTICAST ADDRESS ALLOCATION ▸ List which of the scopes (local, site-local, link-local) are available ▸ Select a multicast address preventing conflicts
  • 15. BONJOUR ANDROID, IT’S ZEROCONF SERVICE DISCOVERY ▸ Service must be discoverable via identifier and/or type ▸ Discovery without the use of a service-specific protocol and should complete in a timely manner (10s of seconds) ▸ Prompt detection of new services in a timely manner (10s of seconds) D R A F T
  • 16. BONJOUR ANDROID, IT’S ZEROCONF HOW DOES IT WORK? ▸ Each part must start with _ (underscore) ▸ The second part only allows _tcp or _udp _ServiceType._TransportProtocolName. List of common services goo.gl/EXh1g
  • 17. BONJOUR ANDROID, IT’S ZEROCONF WHAT ABOUT ANDROID? ▸ API FROM 4.1 ▸ JMDNS FOR JAVA ▸ APPLE NATIVE (C++) IMPLEMENTATION
  • 18. BONJOUR ANDROID, IT’S ZEROCONF JMDNS FOR JAVA ▸ Easy to implement ▸ Runs on the main thread, unless we specify otherwise ▸ Distributed as JAR or via Maven repo ▸ Long start-up time ▸ Compatible with all the Android versions
  • 19. BONJOUR ANDROID, IT’S ZEROCONF WHAT ABOUT ANDROID? ▸ API FROM 4.1 ▸ JMDNS FOR JAVA ▸ APPLE NATIVE (C++) IMPLEMENTATION
  • 20. BONJOUR ANDROID, IT’S ZEROCONF APPLE NATIVE (C++) IMPLEMENTATION ▸ Ported to Android by Apple ▸ Open-sourced ▸ Needs Android NDK ▸ Few projects come with it already packed in ▸ Short startup time ▸ More complex logic
  • 21. BONJOUR ANDROID, IT’S ZEROCONF WHAT ABOUT ANDROID? ▸ API FROM 4.1 ▸ JMDNS FOR JAVA ▸ APPLE NATIVE (C++) IMPLEMENTATION
  • 22. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API ▸ From Android 4.1, custom attributes added with 5.1 (API 21) ▸ Already asynchronous, with return on the main thread ▸ Verbose, but easy to implement ▸ Based on two steps: discovery and resolution ▸ Only one service can be resolved at a time http://developer.android.com/training/connect-devices-wirelessly/nsd.html
  • 23. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - SERVER NsdServiceInfo serviceInfo = new NsdServiceInfo(); serviceInfo.setServiceName("DroidConService"); serviceInfo.setServiceType("_http._tcp."); serviceInfo.setPort(randomPort); nsdManager = Context.getSystemService(Context.NSD_SERVICE); nsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener); Remember to unregister the service upon app closing!
  • 24. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class Resolver extends NsdManager.ResolveListener { @Override public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {} @Override public void onServiceResolved(NsdServiceInfo serviceInfo) { // here we can use our resolved service } }; Resolve resolveListener = new Resolve();
  • 25. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class Resolver extends NsdManager.ResolveListener { @Override public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {} @Override public void onServiceResolved(NsdServiceInfo serviceInfo) { // here we can use our resolved service } }; Resolve resolveListener = new Resolve();
  • 26. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class SimpleDiscoveryListener extends NsdManager.DiscoveryListener { @Override public void onDiscoveryStarted(String regType) {} @Override public void onServiceFound(NsdServiceInfo service) { if (service.getServiceName().contains(“DroidConService")){ nsdManager.resolveService(service, resolveListener); } } @Override public void onServiceLost(NsdServiceInfo service) {} @Override public void onDiscoveryStopped(String serviceType) {} @Override public void onStartDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); } @Override public void onStopDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); }};
  • 27. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT class SimpleDiscoveryListener extends NsdManager.DiscoveryListener { @Override public void onDiscoveryStarted(String regType) {} @Override public void onServiceFound(NsdServiceInfo service) { if (service.getServiceName().contains(“DroidConService")){ nsdManager.resolveService(service, resolveListener); } } @Override public void onServiceLost(NsdServiceInfo service) {} @Override public void onDiscoveryStopped(String serviceType) {} @Override public void onStartDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); } @Override public void onStopDiscoveryFailed(String serviceType, int errorCode) { nsdManager.stopServiceDiscovery(this); }};
  • 28. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener(); nsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, discoveryListener); nsdManager.stopServiceDiscovery(discoveryListener);
  • 29. BONJOUR ANDROID, IT’S ZEROCONF ANDROID API - CLIENT SimpleDiscoveryListener discoveryListener = new SimpleDiscoveryListener(); nsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, discoveryListener); nsdManager.stopServiceDiscovery(discoveryListener);
  • 30. ARE THERE BETTER WAYS OF DOING IT?
  • 31. YES, THERE ARE! ARE THERE BETTER WAYS OF DOING IT
  • 32. BONJOUR ANDROID, IT’S ZEROCONF BETTER WAYS OF DOING IT ▸ better-zeroconf ▸ RxDNSSD ▸ RxBonjour ▸ ZeRxConf ▸ android-mdns ▸ JmDNS ▸ Apple mDNS ▸ Apple mDNS ▸ JmDNS + Android Native APIs ▸ Apple mDNS
  • 34. Q & A CHECK THE REPO @ GITHUB.COM/ENNOVA-IT/DROIDCON-DEMO
  • 35. BONJOUR ANDROID, IT’S ZEROCONF THANKS FOR WATCHING!