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 peer-to-peer bluetooth network


In this recipe, we will create a peer-to-peer bluetooth network, which we will use to exchange text messages. To create a bluetooth peer-to-peer network, we will use Apple's Game Kit framework. So, we will need to add the Gamekit framework to our project.

The downloadable code for this project creates a peer-to-peer network that is used to exchange text messages. Each individual message that is sent over the bluetooth network can have a maximum size of 90 KB. If the data that we are sending is greater then 90 KB, we will need to break the data apart and send it as multiple messages.

We will be implementing the GKPeerPickerController and GKSession delegate methods. The GKPeerPickerController method provides a standard user interface, which allows one iOS device to connect to another iOS device. Once the two devices are connected, a GKSession object is returned. The GKSession object is used to send and receive data between the two peers.

When the peer...