O'Reilly logo

Learning Cocoa with Objective-C, 3rd Edition by Jonathon Manning, Paris Buttfield-Addison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13. Networking

Many chapters in books like this begin with something like, “The ability to talk to computers over the network is an increasingly popular feature.” We won’t bore you with that. Suffice to say—it’s the 21st century, networking is huge, and you need your app to send and receive data. Let’s learn how.

In this chapter, you’ll learn how to make connections over the network and access resources with URLs. You’ll also learn how to use Bonjour to discover nearby network services so that you can connect to them. Finally, you’ll learn how to create your own network service and receive connections from other devices.

All of the content in this chapter applies to both OS X and iOS.

Connections

At the lowest level, network connections in Cocoa are the same as in every other popular OS. The Berkeley sockets API, the fundamental networking and connectivity API used on Windows and almost every Unix OS (which includes OS X and iOS), is available, allowing you to make connections to any computer on the network and send and receive data.

However, working with such a low-level API can be cumbersome, especially when you want to use popular, higher-level protocols like HTTP. To make things more fun for developers like us, Cocoa provides a higher-level API that provides a simple interface for accessing content via URLs on the Internet.

Note

A URL is a Uniform Resource Locator. It’s a location on the Internet, and specifies the location of the server to connect to, the protocol to use, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required