Python Network Programming Cookbook


Python Network Programming Cookbook
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Demonstrates how to write various besopke client/server networking applications using standard and popular third-party Python libraries
  • Learn how to develop client programs for networking protocols such as HTTP/HTTPS, SMTP, POP3, FTP, CGI, XML-RPC, SOAP and REST
  • Provides practical, hands-on recipes combined with short and concise explanations on code snippets

Book Details

Language : English
Paperback : 234 pages [ 235mm x 191mm ]
Release Date : March 2014
ISBN : 1849513465
ISBN 13 : 9781849513463
Author(s) : Dr. M. O. Faruque Sarker
Topics and Technologies : All Books, Cookbooks, Open Source


Table of Contents

Preface
Chapter 1: Sockets, IPv4, and Simple Client/Server Programming
Chapter 2: Multiplexing Socket I/O for Better Performance
Chapter 3: IPv6, Unix Domain Sockets, and Network Interfaces
Chapter 4: Programming with HTTP for the Internet
Chapter 5: E-mail Protocols, FTP, and CGI Programming
Chapter 6: Screen-scraping and Other Practical Applications
Chapter 7: Programming Across Machine Boundaries
Chapter 8: Working with Web Services – XML-RPC, SOAP, and REST
Chapter 9: Network Monitoring and Security
Index
  • Chapter 1: Sockets, IPv4, and Simple Client/Server Programming
    • Introduction
    • Printing your machine's name and IPv4 address
    • Retrieving a remote machine's IP address
    • Converting an IPv4 address to different formats
    • Finding a service name, given the port and protocol
    • Converting integers to and from host to network byte order
    • Setting and getting the default socket timeout
    • Handling socket errors gracefully
    • Modifying socket's send/receive buffer sizes
    • Changing a socket to the blocking/non-blocking mode
    • Reusing socket addresses
    • Printing the current time from the Internet time server
    • Writing a SNTP client
    • Writing a simple echo client/server application
  • Chapter 2: Multiplexing Socket I/O for Better Performance
    • Introduction
    • Using ForkingMixIn in your socket server applications
    • Using ThreadingMixIn in your socket server applications
    • Writing a chat server using select.select
    • Multiplexing a web server using select.epoll
    • Multiplexing an echo server using Diesel concurrent library
  • Chapter 3: IPv6, Unix Domain Sockets, and Network Interfaces
    • Introduction
    • Forwarding a local port to a remote host
    • Pinging hosts on the network with ICMP
    • Waiting for a remote network service
    • Enumerating interfaces on your machine
    • Finding the IP address for a specific interface on your machine
    • Finding whether an interface is up on your machine
    • Detecting inactive machines on your network
    • Performing a basic IPC using connected sockets (socketpair)
    • Performing IPC using Unix domain sockets
    • Finding out if your Python supports IPv6 sockets
    • Extracting an IPv6 prefix from an IPv6 address
    • Writing an IPv6 echo client/server
  • Chapter 4: Programming with HTTP for the Internet
    • Introduction
    • Downloading data from an HTTP server
    • Serving HTTP requests from your machine
    • Extracting cookie information after visiting a website
    • Submitting web forms
    • Sending web requests through a proxy server
    • Checking whether a web page exists with the HEAD request
    • Spoofing Mozilla Firefox in your client code
    • Saving bandwidth in web requests with the HTTP compression
    • Writing an HTTP fail-over client with resume and partial downloading
    • Writing a simple HTTPS server code with Python and OpenSSL
  • Chapter 5: E-mail Protocols, FTP, and CGI Programming
    • Introduction
    • Listing the files in a remote FTP server
    • Uploading a local file to a remote FTP server
    • E-mailing your current working directory as a compressed ZIP file
    • Downloading your Google e-mail with POP3
    • Checking your remote e-mail with IMAP
    • Sending an e-mail with an attachment via Gmail SMTP server
    • Writing a guestbook for your (Python-based) web server with CGI
  • Chapter 6: Screen-scraping and Other Practical Applications
    • Introduction
    • Searching for business addresses using the Google Maps API
    • Searching for geographic coordinates using the Google Maps URL
    • Searching for an article in Wikipedia
    • Searching for Google stock quote
    • Searching for a source code repository at GitHub
    • Reading news feed from BBC
    • Crawling links present in a web page
  • Chapter 7: Programming Across Machine Boundaries
    • Introduction
    • Executing a remote shell command using telnet
    • Copying a file to a remote machine by SFTP
    • Printing a remote machine's CPU information
    • Installing a Python package remotely
    • Running a MySQL command remotely
    • Transferring files to a remote machine over SSH
    • Configuring Apache remotely to host a website
  • Chapter 8: Working with Web Services – XML-RPC, SOAP, and REST
    • Introduction
    • Querying a local XML-RPC server
    • Writing a multithreaded multicall XML-RPC server
    • Running an XML-RPC server with a basic HTTP authentication
    • Collecting some photo information from Flickr using REST
    • Searching for SOAP methods from an Amazon S3 web service
    • Searching Google for custom information
    • Searching Amazon for books through product search API
  • Chapter 9: Network Monitoring and Security
    • Introduction
    • Sniffing packets on your network
    • Saving packets in the pcap format using the pcap dumper
    • Adding an extra header in HTTP packets
    • Scanning the ports of a remote host
    • Customizing the IP address of a packet
    • Replaying traffic by reading from a saved pcap file
    • Scanning the broadcast of packets

Dr. M. O. Faruque Sarker

Dr. M. O. Faruque Sarker is a software architect, and DevOps engineer who's currently working at University College London (UCL), United Kingdom. In recent years, he has been leading a number of Python software development projects, including the implementation of an interactive web-based scientific computing framework using the IPython Notebook service at UCL. He is a specialist and an expert in open source technologies, for example, e-learning and web application platforms, agile software development, and IT service management methodologies such as DSDM Atern and ITIL Service management frameworks.

Dr. Sarker received his PhD in multirobot systems from University of South Wales where he adopted various Python open source projects for integrating the complex software infrastructure of one of the biggest multirobot experiment testbeds in UK. To drive his multirobot fleet, he designed and implemented a decoupled software architecture called hybrid event-driven architecture on D-Bus. Since 1999, he has been deploying Linux and open source software in commercial companies, educational institutions, and multinational consultancies. He was invited to work on the Google Summer of Code 2009/2010 programs for contributing to the BlueZ and Tahoe-LAFS open source projects.

Currently, Dr. Sarker has a research interest in self-organized cloud architecture. In his spare time, he likes to play with his little daughter, Ayesha, and is keen to learn about child-centric educational methods that can empower children with self-confidence by engaging with their environment.

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Python Network Programming Cookbook +    SQL Server Analysis Services 2012 Cube Development Cookbook =
50% Off
the second eBook
Price for both: ₨693.00

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Develop TCP/IP networking client/server applications
  • Administer local machines' IPv4/IPv6 network interfaces
  • Write multi-purpose efficient web clients for HTTP and HTTPS protocols
  • Create e-mail clients to work with common e-mail protocols such as SMTP, POP3, IMAP, and so on.
  • Scrape websites and search for useful information
  • Perform remote system administration tasks over Telnet and SSH connections
  • Interact with popular websites via web services such as XML-RPC, SOAP, and REST APIs
  • Monitor and analyze major common network security vulnerabilities

In Detail

Python is an excellent language to use to write code and have fun by prototyping applications quickly. The presence of lots of third-party libraries, also known as batteries, makes it even more easier and faster to prototype an application or to implement a new algorithm. If you are interested in creating the building blocks for many practical web and networking applications that rely on networking protocols then this book is a must-have.

This book highlights major aspects of network programming in Python starting from writing simple networking clients, to developing complex screen-scraping and network security monitoring scripts. It creates the building blocks for many practical web and networking applications that rely on various networking protocols. This book presents the power and beauty of Python in solving the numerous real-world tasks in the area of network programming, system and network administration, network monitoring, and web-application development.

This book develops your ability to solve a wide range of network programming tasks in Python. We will start by exploring the Python standard library functions to create client/server network and manipulate your local networking resources available under both IPv4 and IPv6. The practical focus continues with creating web and email clients, scraping web pages, fetching information from various websites, and searching for information on the Web such as Amazon, Flickr, and other sites. It further develops your skills to analyze your network security vulnerabilities using advanced network packet capture and analysis techniques.

Approach

An easy-to-follow guide full of hands-on examples on real-world networking tasks. It covers the advanced topics of network programming in Python using a set of selected recipes.

Who this book is for

If you are a network programmer, system/network administrator, or a web application developer, this book is ideal for you. You should have a basic familiarity with the Python programming language and TCP/IP networking concepts. However if you are a novice, you will develop an understanding of the concepts as you progress with this book. This book will serve as a supplementary material for developing hands-on skills in any academic course on network programming.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software