iOS and OS X Network Programming Cookbook
eBook - ePub

iOS and OS X Network Programming Cookbook

  1. 300 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

iOS and OS X Network Programming Cookbook

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Darwin, which forms the core set of components for OS X and iOS, is compatible with the Single UNIX Specification Version 3 and POSIX UNIX. Therefore OS X and iOS are UNIX operating systems. While there are numerous books and articles written to teach network development in a UNIX environment there is surprisingly little dedicated to teaching network development specifically in an Apple environment. In this book we will be covering the standard UNIX networking stack with BSD Sockets as well as Apples frameworks like CFNetworking and Bonjour.

"iOS and OS X Network Programming Cookbook" is an enthralling code-focused book on developing client and server applications for the iOS and OS X environments. You will learn how to integrate a number of Unix (BSD Sockets), Apple specific (CFNetworking, NSMutableURLRequest, Bonjour) and third party APIs (AFNetworking, MKNetworking) with your own apps.

"iOS and OS X Network Programming Cookbook" begins by showing you how to build both client and server applications using the BSD Socket Library as well as Apples CFNetworking library. The sample code includes samples for both iOS and OS X.

It then covers how to add Bonjour to publish, find, and connect to services. This can be used to create peer-to-peer applications over local networks. Finally it shows how to integrate third-party libraries like Libnet, LibPCAP, AFNetworking, and MKNetworking with the readers apps.

A lot of developers do not realize that iOS is a full UNIX-based operating system that contains a full set of networking APIs. These APIs can be used to create both client- and server-based applications in the iOS environment as well as OS X. Using the Apples Bonjour library you will learn how to publish, find, and connect the services together without hardcoding the connection information. There are also a number of third-party APIs that can be used to easily connect iOS and OS X applications to web-based services. Finally this book will cover several low level libraries like LibNET and LibPCAP on the OS X environment.

"iOS and OS X Network Programming Cookbook" will cover several UNIX, Apple, and third-party libraries and APIs. The book will show the user how to integrate all of these libraries and APIs with their applications.

Approach

This book follows a recipe-based approach that will heavily focus on the code and how to integrate the samples with the readers projects.Each recipe consists of one or more methods that you can put directly into your app and use.

Who this book is for

This book is ideal for developers that want to create network applications for the Apple OS X or iOS platforms. All examples are written in Objective-C using XCode as the IDE. Knowledge of Objective-C and X-Code is essential.

Frequently asked questions

Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weā€™ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access iOS and OS X Network Programming Cookbook by Jon Hoffman in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming. We have over one million books available in our catalogue for you to explore.

Information

Year
2014
ISBN
9781849698085
Edition
1

iOS and OS X Network Programming Cookbook


Table of Contents

iOS and OS X Network Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. BSD Socket Library
Introduction
Finding the byte order of your device
Getting ready
How to do itā€¦
How it worksā€¦
Retrieving network address information
Getting ready
How to do itā€¦
How it worksā€¦
Performing a network address resolution
Getting ready
How to do itā€¦
Creating the AddrInfo header file
Creating the AddrInfo implementation file
Using the AddrInfo class to perform the address/hostname resolution
How it worksā€¦
Creating an echo server
Getting ready
How to do itā€¦.
Creating the BSDSocketServer header file
Creating the BSDSocketServer implementation file
Using the BSDSocketServer class to start the echo server
How it worksā€¦
Creating an echo client
Getting ready
How to do itā€¦
Creating the BSDSocketClient header file
Creating the BSDSocketClient implementation file
Using the BSDSocketClient to connect to our echo server
How it worksā€¦
Creating a data server
Getting ready
How to do itā€¦
Updating the BSDSocketServer header file
Updating the BSDSocketServer implementation file
Using the BSDSocketServer to create our data server
How it worksā€¦
Creating a data client
Getting ready
How to do itā€¦
Updating the BSDSocketClient header file
Updating the BSDSocketClient implementation file
Using the BSDSocketClient to connect to our data server
How it worksā€¦
2. Apple Low-level Networking
Introduction
Retrieving network address information
Getting ready
How to do it...
How it worksā€¦
Performing a network address resolution
Getting ready
How to do itā€¦
Creating the CFNetworkUtilities header file
Creating the CFNetworkUtilities implementation file
How it works...
Creating an echo server
Getting ready
How to do it...
Creating the CFSocketServer header file
Creating the CFSocketServer implementation file
How it works...
Creating an echo client
Getting ready
How to do it...
Creating the CFSocketClient header file
Creating the CFSocketClient implementation file
Using the CFSocketClient class
How it works...
Creating a server to receive data
Getting ready
How to do itā€¦
Updating the CFSocketServer header file
Updating the CFSocketServer implementation file
Using the CFSocketServer class
How it works...
Creating a client to send data
Getting ready
How to do it...
Updating the CFSocketClient header file
Updating the CFSocketClient implementation file
How it works...
Checking the network status
Getting ready
How to do it...
Creating the NetworkDetect header file
Creating the NetworkDetect implementation file
How it works...
3. Using Libnet
Introduction
Installing libnet
Getting ready
How to do itā€¦
How it worksā€¦
Adding libnet to your project
Getting ready
How to do itā€¦
How it worksā€¦
Resolving names to addresses with libnet
Getting ready
How to do itā€¦
Importing the libnet header
How it worksā€¦
Retrieving local addresses with libnet
Getting ready
How to do itā€¦
Importing the libnet header
Retrieving the local IP and hardware addresses of our device
How it worksā€¦
Constructing a Ping packet with libnet
Getting ready
How to do itā€¦
Importing the libnet header
Defining variables
Initiating the libnet context
Setting the target and source IP addresses
Creating a random number to be used as an identifier
Building the ICMP header
Building the IPv4 header
Injecting the ICMP packet
How it worksā€¦
Constructing a UDP packet with libnet
Getting ready
How to do itā€¦
Importing the libnet header
Initiating the libnet context
Setting the target and source IP addresses
Creating a random number to be used as an identifier
Building the UDP header
Building the IPv4 header
Injecting the packet
How it worksā€¦
Constructing a TCP packet with libnet
Getting ready
How to do itā€¦
Importing the libnet header
Defining variables
Initiating the libnet context
Setting the target and source IP addresses
Creating a random number to be used as an identifier
Building the TCP header
Building the IPv4 header
Injecting the packet
How it worksā€¦
4. Using Libpcap
Introduction
Adding libpcap to your project
Getting ready
How to do itā€¦
How it worksā€¦
Retrieving network device information
Getting ready
How to do itā€¦
How it worksā€¦
Capturing packets
Getting ready
How to do itā€¦
How it worksā€¦
Decoding Ethernet headers
Getting ready
How to do itā€¦
How it worksā€¦
Decoding IP headers
Getting ready
How to do itā€¦
How it worksā€¦
Decoding ARP headers
Getting ready
How to do itā€¦
How it worksā€¦
Decoding TCP headers
Getting ready
How to do itā€¦
How it worksā€¦
Decoding UDP headers
Getting ready
How to do itā€¦
How it worksā€¦
Decoding ICMP headers
Getting ready
How to do itā€¦
How it worksā€¦
Filtering packets
Getting ready
How to do itā€¦
How it worksā€¦
Saving a capture file
Getting ready
How to do itā€¦
How it worksā€¦
Creating a simple port scanner using libnet and libpcap together
Getting ready
How to do itā€¦
How it worksā€¦
5. Apple High-level Networking
Introduction
Performing HTTP(S) synchronous GET requests
Getting ready
How to do itā€¦
Creating the WebServiceConnectSynchronous header file
Creating the sendGetRequest:toURL: method
How it w...

Table of contents

  1. iOS and OS X Network Programming Cookbook