Book Image

iOS and OS X Network Programming Cookbook

By : Jon Hoffman
Book Image

iOS and OS X Network Programming Cookbook

By: Jon Hoffman

Overview of this book

Table of Contents (15 chapters)
iOS and OS X Network Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a client to send data


In the Creating a data server recipe from Chapter 1, BSD Socket Library, we created a server that can receive incoming data. In this recipe, we will create a client application that will send images to that server.

Also note that the data client and server applications created in Chapter 1, BSD Socket Library, can be used interchangeably with the data client and server applications created in this chapter.

We will be expanding the CFSocketClient class that we wrote in the Creating a data client recipe from Chapter 1, BSD Socket Library, to handle both the echo client and the data client.

Getting ready

This recipe is compatible with both iOS and OS X. No extra frameworks or libraries are required.

How to do it...

Let's get started!

Updating the CFSocketClient header file

In the header file, we add the sendDataToSocket:withData: method:

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, CFNetworkClientErrorCode) {
  NOERRROR,
  SOCKETERROR,
  CONNECTERROR...