![]() The company that develops Discovery - DNS-SD Browser is Lily Ballard. ![]() First take a look in the Server project at the ServerController class.Discovery - DNS-SD Browser is a free app for iOS published in the System Maintenance list of apps, part of System Utilities. That’s the extent of this week’s functionality not very exciting, but it will get better next time, when we will try to send an image from one app to the other. Though nothing will appear to change, the connection has now been made. You can now select the server, and press Connect. The server should appear in the list, indicating it was located. To begin the client searching for services, click the ‘Search’ button in the client app. You can run both on the same computer at the same time, and everything will work fine.ĭownload the client project, and the server project, and build and run each at the same time. We need two separate projects for this: a client application, and a server application. (Note that a ‘local network’ in the context of Bonjour exists between two devices when they can send each other data without that data passing through a router, or any other form of network address translation.) Client and Server It does not setup any sort of connection - it just finds and reports the existence of services. This class seeks out the services of a particular type on the local network, and reports them. The server publishes its service, and any clients on the network can then look for the service using the NSNetServiceBrowser class. For example, I’ve been working recently on getting the Mac and iPhone versions of Mental Case to sync via wifi in that case, the service vended was simply the ability to perform a certain type of sync. A NSNetService represents any service that a server would like to vend. The Cocoa interface to Bonjour has two classes: NSNetServiceBrowser and NSNetService. For the overly pedantic, Bonjour is Apple’s implementation of Zeroconf, but you really don’t need to know too much about how it works to use it. For this, we are going to use Apple’s Bonjour. In this tutorial, we are going to look at the first challenge of connecting two systems, that of locating each other on a local network. For now, we need to address a more pressing issue: how do our devices find each other? Finding Each Other We will be building our messaging layer on top of AsyncSocket, but we are going to leave that for the next tutorial. The one we will be using is AsyncSocket, an open-source class which is both powerful, easy to use, and will run on iPhone and Mac. For a more advanced socket-abstraction class, you need to look further afield. Using NSFileHandle is one option, but probably not the best. Yes, you read right, Mac OS X basically sees sockets as special file handles, which you can serially read from, or write to. Although you can use the C API for BSD sockets directly, it is quite complex, and - when using Cocoa - you are better off using BSD sockets indirectly via a socket-abstraction class.Īpple actually supplies such a class, the ever versatile NSFileHandle. A socket on one computer can be connected to a socket on another computer, and raw data can be streamed across it. SocketsĪt the lowest level of OS X, we have BSD sockets. This is a set of functions and classes that allow you to easily send messages - chunks of data - from one system to another, without having to think too much about it. ![]() ![]() This brings us to point (2): low-level networking can be a little tricky, which means you will probably want to build your own ‘Messaging Library’, to reduce the complexity and chance of bugs. If you want to communicate iPhone-to-iPhone, Mac-to-iPhone, iPhone-to-PlatformX, or Mac-to-PlatformX, you will need something more low-level. The downside of DO is that it works only on Macs, not on iPhones, and not on any other platform. The Mac has a technology called ‘Distributed Objects’ (DO), which makes it quite easy for one process to talk to another, even if it is on another computer.
0 Comments
Leave a Reply. |