HTTP Communication

Now for the second part of this chapter – adding web server functionality to CocoaServer so that it can receive HTTP requests from its clients.

Writing a web server in Objective-C

CocoaServer advertises an HTTP service, so it needs to be able to accept HTTP requests. Then, clients, like Notified, can use NSURLConnection to exchange information with CocoaServer.

Writing a web server from scratch is not a task we can cover in this book. Instead, we have modified some of Apple’s sample code to lay the foundation of a web server in Objective-C. This code is available at http://www.bignerdranch.com/solutions/iOSProgramming.zip in the solution directory for the CocoaServer project.

The web server code is encapsulated in two classes: ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.