![]() The TXT record has the same name as the corresponding SRV record, and can contain a small amount of additional information about the service instance, typically no more than 100–200 bytes at most. ![]() That’s what official documentation says about it: One of the most important parts of Bonjour API is ability to share some metadata about a service, also known as TXT records. This API is available starting from API level 16 (Android 4.1) and works well in general, though it doesn’t cover all Bonjour functionality. Google provides Network Service Discovery API that uses the same technology Apple uses in Mac OS X and iOS (Oh, I’ve forgotten to tell you that Bonjour is open-source). Is there a standard Android API for it? Yes. You print documents via wifi on your printer - Bonjour is here again. You are playing games with your friends via wifi - it’s Bonjour. For example: you try to connect to Chromecast in your living room - it’s Bonjour. Google uses this technology in lots of their projects. What about Android? Can we use this powerful technology in our Android projects? Yes. You can find more information about Bonjour in official documentation. You should understand that Bonjour is only a technology for services discovery, all connection you have to do by yourself anyway. Also applications can discover all available services at any domain. All services are registered in some domain (that’s a mandatory parameter for all services and you can find domain naming conventions here). Any application in your operating system can register a service and assign it to an opened port on your computer (actually Bonjour does not guarantee that a port in service’s metadata is opened and connected to the app that registered this service). A Bonjour term for a device on a network is “service”. In other words, Bonjour is a software component that is used for other devices discovery (PC, Mac, smartphones, printers, etc) in a network via all available interfaces. Bonjour makes it easy to discover, publish, and resolve network services with a sophisticated, yet easy-to-use, programming interface that is accessible from Cocoa, Ruby, Python, and other languages. Bonjour locates devices such as printers, other computers, and the services that those devices offer on a local network using multicast Domain Name System (mDNS) service records.īonjour, also known as zero-configuration networking, enables automatic discovery of devices and services on a local network using industry standard IP protocols. We’ll create a Client and Connection, to handle sending messages, we will start with Connection.Bonjour is Apple’s implementation of Zero-configuration networking (Zeroconf), a group of technologies that includes service discovery, address assignment, and hostname resolution. Our second task: do something useful with our system (ie. Yay! The client’s phone was able to discover the server. The client device shows: browser.stateUpdateHandler ready 07:47:02.461367+0100 MultiConnect browser.browseResultsChangedHandler result: Result(nw: endpoint: server._superapp._tcplocal., interfaces:, metadata: ) 07:47:02.724386+0100 MultiConnect browser.browseResultsChangedHandler result: Result(nw: endpoint: server._superapp._tcplocal., interfaces:, metadata: ) On my server device console shows: listener.stateUpdateHandler waiting(POSIXErrorCode: Network is down) listener.stateUpdateHandler ready Now let’s run the app on two devices, start the server on the first device and tap the “Client” button on the second one. We want to be able to see logs for both server and client (or browser) simultaneously in the Console.app for that we’ll create a global helper function and we’ll stick it in AppDelegate.swift NSLocalNetworkUsageDescription Why do we use Local Network? Next, we want to use any network available, preferably a local network, and to be able to use the local network on devices running IOS14 we need to add to ist NSLocalNetworkUsageDescription key. The underscores in the type field are required! NSBonjourServices _superapp._tcp In our case, we’ll define one type and we’ll use TCP protocol. The server does the advertising and handles clients, the browser finds available servers (listeners).įirst of all, we need to add NSBonjourServices key to ist ( ), and pass an array of Bonjour service types. To accomplish this task we’ll need a server a browser. Let’s start with the first task: discovering devices using Bonjour ( ) We’ll also use Bonjour service to let clients discover the each others automatically. Today we’ll explore how to send messages between multiple Apple devices using the Network framework, without the need of having external server. IOS/OSX Messaging Using the Network Framework and Bonjour Service (no external server required!).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |