Home Page Icon
Home Page
Table of Contents for
Python Network Programming Cookbook
Close
Python Network Programming Cookbook
by Dr. M. O. Faruque Sarker
Python Network Programming Cookbook
Python Network Programming Cookbook
Table of Contents
Python 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. Sockets, IPv4, and Simple Client/Server Programming
Introduction
Printing your machine's name and IPv4 address
Getting ready
How to do it...
How it works...
Retrieving a remote machine's IP address
How to do it...
How it works...
Converting an IPv4 address to different formats
How to do it...
How it works...
Finding a service name, given the port and protocol
Getting ready
How to do it...
How it works...
Converting integers to and from host to network byte order
How to do it...
How it works...
Setting and getting the default socket timeout
How to do it...
How it works...
Handling socket errors gracefully
How to do it...
How it works...
Modifying socket's send/receive buffer sizes
How to do it...
How it works...
Changing a socket to the blocking/non-blocking mode
How to do it...
How it works...
Reusing socket addresses
How to do it...
How it works...
Printing the current time from the Internet time server
Getting ready
How to do it...
How it works...
Writing a SNTP client
How to do it...
How it works...
Writing a simple echo client/server application
How to do it...
How it works...
2. Multiplexing Socket I/O for Better Performance
Introduction
Using ForkingMixIn in your socket server applications
How to do it...
How it works...
Using ThreadingMixIn in your socket server applications
Getting ready
How to do it...
How it works...
Writing a chat server using select.select
How to do it...
How it works...
Multiplexing a web server using select.epoll
How to do it...
How it works...
Multiplexing an echo server using Diesel concurrent library
Getting ready
How to do it...
How it works...
3. IPv6, Unix Domain Sockets, and Network Interfaces
Introduction
Forwarding a local port to a remote host
How to do it...
How it works...
Pinging hosts on the network with ICMP
Getting ready
How to do it...
How it works...
Waiting for a remote network service
How to do it...
How it works...
Enumerating interfaces on your machine
Getting ready
How to do it...
How it works...
Finding the IP address for a specific interface on your machine
Getting ready
How to do it...
How it works...
Finding whether an interface is up on your machine
Getting ready
How to do it...
How it works...
Detecting inactive machines on your network
Getting ready
How to do it...
How it works...
Performing a basic IPC using connected sockets (socketpair)
Getting ready
How to do it...
How it works...
Performing IPC using Unix domain sockets
How to do it...
How it works...
Finding out if your Python supports IPv6 sockets
Getting ready
How to do it...
How it works...
Extracting an IPv6 prefix from an IPv6 address
How to do it...
How it works...
Writing an IPv6 echo client/server
How to do it...
How it works...
4. Programming with HTTP for the Internet
Introduction
Downloading data from an HTTP server
How to do it...
How it works...
Serving HTTP requests from your machine
How to do it...
How it works...
Extracting cookie information after visiting a website
How to do it...
How it works...
Submitting web forms
Getting ready
How to do it...
How it works...
Sending web requests through a proxy server
Getting ready
How to do it...
How it works...
Checking whether a web page exists with the HEAD request
How to do it...
How it works...
Spoofing Mozilla Firefox in your client code
How to do it...
How it works...
Saving bandwidth in web requests with the HTTP compression
How to do it...
How it works...
Writing an HTTP fail-over client with resume and partial downloading
How to do it...
How it works...
Writing a simple HTTPS server code with Python and OpenSSL
Getting ready
How to do it...
How it works...
5. E-mail Protocols, FTP, and CGI Programming
Introduction
Listing the files in a remote FTP server
Getting ready
How to do it...
How it works...
Uploading a local file to a remote FTP server
Getting ready
How to do it...
How it works...
E-mailing your current working directory as a compressed ZIP file
Getting ready
How to do it...
How it works...
See also
Downloading your Google e-mail with POP3
Getting ready
How to do it...
How it works...
Checking your remote e-mail with IMAP
Getting ready
How to do it...
How it works...
Sending an e-mail with an attachment via Gmail SMTP server
Getting ready
How to do it...
How it works...
Writing a guestbook for your (Python-based) web server with CGI
How to do it...
How it works...
6. Screen-scraping and Other Practical Applications
Introduction
Searching for business addresses using the Google Maps API
Getting ready
How to do it...
How it works...
See also
Searching for geographic coordinates using the Google Maps URL
How to do it...
How it works...
Searching for an article in Wikipedia
Getting ready
How to do it...
How it works...
Searching for Google stock quote
Getting ready
How to do it...
How it works...
Searching for a source code repository at GitHub
Getting ready
How to do it...
How it works...
Reading news feed from BBC
Getting ready
How to do it...
How it works...
Crawling links present in a web page
How to do it...
How it works...
7. Programming Across Machine Boundaries
Introduction
Executing a remote shell command using telnet
Getting ready
How to do it...
How it works...
Copying a file to a remote machine by SFTP
Getting ready
How to do it...
How it works...
Printing a remote machine's CPU information
Getting ready
How to do it...
How it works...
Installing a Python package remotely
Getting ready
How to do it...
How it works...
Running a MySQL command remotely
Getting ready
How to do it...
How it works...
Transferring files to a remote machine over SSH
Getting ready
How to do it...
How it works...
Configuring Apache remotely to host a website
Getting ready
How to do it...
How it works...
8. Working with Web Services – XML-RPC, SOAP, and REST
Introduction
Querying a local XML-RPC server
Getting ready
How to do it...
How it works...
Writing a multithreaded multicall XML-RPC server
How to do it...
How it works...
Running an XML-RPC server with a basic HTTP authentication
How to do it...
How it works...
Collecting some photo information from Flickr using REST
How to do it...
How it works...
Searching for SOAP methods from an Amazon S3 web service
Getting ready
How to do it...
How it works...
Searching Google for custom information
Getting ready
How to do it...
How it works...
Searching Amazon for books through product search API
Getting ready
How to do it...
How it works...
9. Network Monitoring and Security
Introduction
Sniffing packets on your network
Getting ready
How to do it...
How it works...
Saving packets in the pcap format using the pcap dumper
How to do it...
How it works...
Adding an extra header in HTTP packets
How to do it...
How it works...
Scanning the ports of a remote host
How to do it...
How it works...
Customizing the IP address of a packet
How to do it...
How it works...
Replaying traffic by reading from a saved pcap file
How to do it...
How it works...
Scanning the broadcast of packets
How to do it...
How it works...
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Table of Contents
Next
Next Chapter
Python Network Programming Cookbook
Python Network Programming Cookbook
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset