售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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 works…
Performing HTTP(S) synchronous POST requests
Getting ready
How to do it…
Updating the WebServiceConnectSynchronous header file
Creating the sendPostRequest:toUrl: method
How it works…
Performing HTTP(S) asynchronous GET requests
Getting ready
How to do it…
Creating the WebServiceConnectAsynchronous header file
Creating the sendGetRequest:toURL: method
Creating the connection:didReceiveResponse: callback method
Creating the connection:didReceiveData: callback method
Creating the connection:didFailWithError: callback method
Creating the connectionDidFinishLoading: callback method
Creating the connection:willSendRedirect:redirectResponse: callback method
Creating the connection:willCacheResponse: callback method
How it works…
Performing HTTP(S) asynchronous POST requests
Getting ready
How to do it…
Updating the WebServiceConnectAsynchronous header file
Creating the sendPostRequest:toURL: method
How it works…
Parsing an RSS feed with NSXMLParser, NSURL, and NSData
Getting ready
How to do it…
Creating the RSSItem header file
Creating the RSSItem implementation file
Creating the ParseRSS header file
Creating the initWithUrl: constructor
Creating the parseXMLFileAtUrl: method
Creating the parserDidStartDocument: NSXMLParserDelegate method
Creating the parser:parserErrorOccurred: NSXMLParserDelegate method
Creating the parser:didStartElement:namespaceURI:qualifiedName:attributes: NSXMLParserDelegate method
Creating the parser:didEndElement:namespaceURI:qualifiedName: NSXMLParserDelegate method
Creating the parser:foundCharacters: NSXMLParserDelegate method
Creating the parserDidEndDocument: NSXMLParserDelegate method
How it works…
Creating a peer-to-peer bluetooth network
Getting ready
How to do it…
Displaying the GKPeerPickerController
Creating the two delegate methods for GKPeerPickerControllerDelegate
Disconnecting from the peer network
Sending data to the peer
Receiving data from the peer
How it works…
6. Bonjour
Introduction
Publishing a Bonjour service
Getting ready
How to do it...
How it works...
Discovering a Bonjour service
Getting ready
How to do it...
How it works...
Resolving a Bonjour service
Getting ready
How to do it...
How it works...
Creating an echo server that uses Bonjour to advertise the service
Getting ready
How to do it...
How it works...
Creating an echo client that uses Bonjour to discover the service
Getting ready
How to do it...
How it works...
7. AFNetworking 2.0 Library
Introduction
Checking the network connection type and changes
Getting ready
How to do it…
How it works…
Creating a web client using AFHTTPSessionManager
Getting ready
How to do it…
Creating the ITunesClient header file
Creating the sharedClient method
Creating the searchType:withTerm:completion: method
Using the ITunesClient class
How it works…
Creating a custom response serializer
Getting ready
How to do it…
Creating the AlbumInformation header file
Creating the AlbumInformation implementation file
Creating the ITunesResponseSerializer header file
Creating the ITunesResponseSerializer implementation file
Adding ITunesResponseSerializer to our ITunesClient
Using the new ITunesClient class
How it works…
Using the UIImageView+AFNetworking category
Getting ready
How to do it…
Updating the ViewController header file
Updating the viewDidLoad method of the ViewController
Creating the UITableView delegate methods
How it works…
Downloading files with a progress bar
Getting ready
How to do it…
Creating the download task
Adding the progressView
How it works…
8. MKNetworkKit
Introduction
Creating and using the MKNetworkKit engine
Getting ready
How to do it…
Creating the ITunesEngine header file
Creating the ITunesEngine implementation file
Using the ITunesEngine class
How it works…
Uploading a file using MKNetworkKit
Getting ready
How to do it…
Creating the FileUploadEngine header file
Creating the FileUploadEngine implementation file
Using the FileUploadEngine class
How it works…
Downloading a file using MKNetworkKit
Getting ready
How to do it…
Creating the ImageDownloadEngine header file
Creating the ImageDownloadEngine implementation file
How it works…
Using the UIImageView+MKNetworkKitAdditions.h category and caching the images
Getting ready
How to do it…
Creating the ITunesEngine header file
Creating the ITunesEngine implementation file
Adjusting the cache settings
Using the new ITunesEngine class
How it works…
Adding a progress bar to upload or download
Getting ready
How to do it…
Creating the FileDownloadEngine header file
Creating the FileDownloadEngine implementation file
How it works…
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜