ios and os x network programming cookbook

300 471 0
ios and os x network programming cookbook

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info iOS and OS X Network Programming Cookbook Over 50 recipes to develop network applications in both the iOS and OS X environment Jon Hoffman BIRMINGHAM - MUMBAI www.it-ebooks.info iOS and OS X Network Programming Cookbook Copyright © 2014 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: January 2014 Production Reference: 1150114 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84969-808-5 www.packtpub.com Cover Image by Jarosław Blaminsky (milak6@wp.pl) www.it-ebooks.info Credits Author Jon Hoffman Reviewers Chady Kassouf Shahin Katebi Josh Rufer Acquisition Editor Vinay Argekar Lead Technical Editor Ritika Dewani Technical Editors Pratik More Shweta Pant Ritika Singh Nachiket Vartak Copy Editors Dipti Kapadia Kirti Pai Shambhavi Pai Project Coordinator Joel Goveya Proofreader Joanna McMahon Indexer Monica Ajmera Mehta Graphics Yuvraj Mannari Abhinash Sahu Production Coordinator Adonia Jones Cover Work Adonia Jones www.it-ebooks.info About the Author Jon Hoffman has close to 20 years of experience in the eld of Information Technology. Over these 20 years, Jon has worked in the areas of system administration, network administration, network security, development and architecture. Currently, he works as a software engineer at Syn-Tech Systems. He has started a network development blog at http://network-development.blogspot.com that will enhance and expand on the material covered in this book. Over the past ve years, he has developed numerous applications for the iOS platform. These include several apps that he has published in the App Store, apps that he has written for third parties, and numerous enterprise applications. What really drives Jon are the challenges in Information Technology; there is nothing more exhilarating for him than overcoming a challenge. Some of Jon's other interests are watching baseball (Go Sox!) and basketball (Go Celtics!). Jon also really enjoys Taekwondo; he and his eldest daughter Kailey are on pace to get their black belts together in the spring of 2014. I would like to thank my wonderful wife Kim, without whose support, encouragement, patience, and understanding, this book would have never been written. I would also like to thank my two wonderful daughters Kailey and Kara, who have both been my inspiration and driving force since they were born. To my dog, Buddy, maybe one day I will be the person who he thinks I am. I would like to give special thanks to all of the wonderful people at Packt Publishing who have helped me along the way. www.it-ebooks.info About the Reviewers Chady Kassouf is an independent iOS and web development expert. He started programming 21 years ago and hasn't stopped since. Five years ago, he decided to leave his job as a team leader in one of the leading digital agencies, and started his own business. His interests outside of computers include arts, music, and tness. He can be found online at http://chady.net/. Shahin Katebi is a software architect and developer with 10 years of experience in creating apps for various platforms (Mac, iOS, Windows, and the Web). He works as a mobile solutions consultant with different companies, and also works with some startup teams worldwide. He teaches iOS/Mac OS development, and as a mentor at Startup Weekend events, helps startup teams make their own business. He is the founder and team leader at Seeb Co. (http://seeb.co/), a creative mobile app development organization creating apps for customers around the world. www.it-ebooks.info Josh Rufer attended university and majored in graphic arts. As passionate as he was for his traditional artwork, he found far more enjoyment in the art of human interaction. His rst position was as the junior interface designer for a small XP programming group. Without enough work to keep him busy, he quickly outpaced his job title and was promoted to senior user experience engineer. On enhancing his programming skills in Java and C++, he was promoted to the position of junior programmer and again promoted as a senior software engineer. Always looking for more challenges, he formed a one-man design and software engineering rm called Guy Writes Code. This allowed him to focus his free time on the things that most interested him: designing and development for the iPhone and iPad. He has created several public applications for companies such as Metabahn and Camdilleo Media. He is currently working on iPad-based training and simulation applications, including augmented reality training on the iPad. When possible, Josh has helped with fact checking and technical editing for books such as Deploying with JRuby by Joe Kutner. www.it-ebooks.info www.PacktPub.com Support les, eBooks, discount offers and more You might want to visit www.PacktPub.com for support les and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub les available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. www.it-ebooks.info www.it-ebooks.info Table of Contents Preface 1 Chapter 1: BSD Socket Library 7 Introduction 7 Finding the byte order of your device 10 Retrieving network address information 12 Performing a network address resolution 16 Creating an echo server 22 Creating an echo client 31 Creating a data server 38 Creating a data client 42 Chapter 2: Apple Low-level Networking 45 Introduction 45 Retrieving network address information 46 Performing a network address resolution 48 Creating an echo server 55 Creating an echo client 63 Creating a server to receive data 68 Creating a client to send data 76 Checking the network status 78 Chapter 3: Using Libnet 83 Introduction 83 Installing libnet 89 Adding libnet to your project 91 Resolving names to addresses with libnet 93 Retrieving local addresses with libnet 97 Constructing a Ping packet with libnet 100 www.it-ebooks.info [...]... MKNetworkKit 253 Downloading a file using MKNetworkKit 258 Using the UIImageView+MKNetworkKitAdditions.h category and caching the images 261 Adding a progress bar to upload or download 266 Index 271 iii www.it-ebooks.info www.it-ebooks.info Preface Darwin forms the core set of components for OS X and iOS, and is compatible with Single UNIX Specification Version 3 and POSIX UNIX Therefore, OS X and iOS. .. which Mac OS X and iOS are based This means that both OS X and iOS contain the BSD Socket Library The last paragraph is very important to understand when you begin thinking about creating network applications for the iOS platform, because almost any code example that uses the BSD Socket Library will work on the iOS platform The biggest difference between using the BSD Socket API on any standard Unix platform... Unix operating systems This means that OS X and iOS use the same basic networking stack that all Unix operating systems use Apple has added several frameworks on top of the basic Unix networking stack This includes frameworks such as CFNetworking and Bonjour, as well as classes such as NSURLConnection There are also several outstanding third-party frameworks written specifically for OS X and/ or iOS. .. Chapter 7, AFNetworking 2.0 Library, shows the reader how to retrieve and send text as well as data to and from remote servers by using the AFNetworking library AFNetworking is an amazing network library for iOS and OS X It is built on top of Apple's foundation framework and is incredibly easy to use Chapter 8, MKNetworkKit, shows the reader how to retrieve and send text as well as data to and from remote... Low-level Networking, and Chapter 3, Using Libnet, can be applied to both OS X and iOS developers Enterprise developers will find the examples in the book extremely helpful while connecting their applications with the backend servers Whether these connections are custom socket connections or web APIs, the examples in this book will be invaluable resources to an Enterprise developer iOS and OS X App Store... by two outstanding third-party frameworks What this book covers Chapter 1, BSD Socket Library, shows the reader how they can use the BSD Socket Library in their iOS and OS X applications While this chapter will show them how to obtain network address information and also how to check the network status, the primary focus will be on creating client/server applications for both iOS and OS X devices We... remote servers by using the MKNetworkKit library MKNetworkKit is an awesome networking framework written in Objective-C The framework is based on blocks and is ARC ready What you need for this book To follow the examples in this book, the reader should have a good understanding of iOS and OS X development techniques, as well as a good understanding of Objective-C and the Xcode development environment... create and send out individual packets Chapter 4, Using Libpcap, shows how to use libpcap with an OS X application and will end by building a utility to capture packets This chapter is written specifically for OS X Libpcap is a packet-capture library that has been complied for virtually every Unix/Linux distribution, and this includes the OS X environment, but unfortunately it does not include iOS Chapter... platform and the iOS platform is that the iOS platform does not support forking of processes You will need to use multiple threads rather than multiple processes The BSD Socket API can be used to build both client and server applications; in this chapter, we will be building both types of applications In the downloadable code, you will find server/ client applications for both the iOS and OS X platforms... byteordering communication You will need to account for this by using the Network- toHost and Host-to -Network functions to convert between the byte order of your device and the byte order of the network The byte order of the device is commonly referred to as the host byte order, and the byte order of the network is commonly referred to as the network byte order The discussion on byte order does lead us directly . www.it-ebooks.info iOS and OS X Network Programming Cookbook Over 50 recipes to develop network applications in both the iOS and OS X environment Jon Hoffman BIRMINGHAM - MUMBAI www.it-ebooks.info iOS and OS. and POSIX UNIX. Therefore, OS X and iOS are considered to be Unix operating systems. This means that OS X and iOS use the same basic networking stack that all Unix operating systems use. Apple. 266 Index 271 www.it-ebooks.info www.it-ebooks.info Preface Darwin forms the core set of components for OS X and iOS, and is compatible with Single UNIX Specication Version 3 and POSIX UNIX. Therefore,

Ngày đăng: 01/08/2014, 17:07

Từ khóa liên quan

Mục lục

  • Cover

  • Copyright

  • Credits

  • About the Author

  • About the Reviewers

  • www.PacktPub.com

  • Table of Contents

  • Preface

  • Chapter 1: BSD Socket Library

    • Introduction

    • Finding the byte order of your device

    • Retrieving network address information

    • Performing network address resolution

    • Creating an echo server

    • Creating an echo client

    • Creating a data server

    • Creating a data client

    • Chapter 2: Apple Low-level Networking

      • Introduction

      • Retrieving network address information

      • Performing network address resolution

      • Creating an echo server

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan