Python Network Programming Cookbook

Python Network Programming Cookbook: Over 70 detailed recipes to develop practical solutions for a wide range of real-world network programming tasks

Download

Introduction

All praises be to God! I am glad that this book is now published, and I would like to thank everyone behind the publication of this book. This book is an exploratory guide to network programming in Python. It has touched a wide range of networking protocols such as TCP/ UDP, HTTP/HTTPS, FTP, SMTP, POP3, IMAP, CGI, and so forth. With the power and interactivity of Python, it brings joy and fun to develop various scripts for performing real-world tasks on network and system administration, web application development, interacting with your local and remote network, low-level network packet capture and analysis, and so on. The primary focus of this book is to give you a hands-on experience on the topics covered. So, this book covers less theory, but it's packed with practical materials.

This book is written with a "devops" mindset where a developer is also more or less in charge of operation, that is, deploying the application and managing various aspects of it, such as remote server administration, monitoring, scaling-up, and optimizing for better performance. This book introduces you to a bunch of open-source, third-party Python libraries, which are awesome to use in various usecases. I use many of these libraries on a daily basis to enjoy automating my devops tasks. For example, I use Fabric for automating software deployment tasks and other libraries for other purposes, such as, searching things on the Internet, screenscraping, or sending an e-mail from a Python script.
I hope you'll enjoy the recipes presented in this book and extend them to make them even more powerful and enjoyable.

What this book covers
Chapter 1, Sockets, IPv4, and Simple Client/Server Programming, introduces you to Python's core networking library with various small tasks and enables you to create your first client-server application.

Chapter 2, Multiplexing Socket I/O for Better Performance, discusses various useful techniques for scaling your client/server applications with default and third-party libraries.

Chapter 3, IPv6, Unix Domain Sockets, and Network Interfaces, focuses more on administering your local machine and looking after your local area network.

Chapter 4, Programming with HTTP for the Internet, enables you to create a mini commandline browser with various features such as submitting web forms, handling cookies, managing partial downloads, compressing data, and serving secure contents over HTTPS.

Chapter 5, E-mail Protocols, FTP, and CGI Programming, brings you the joy of automating your FTP and e-mail tasks such as manipulating your Gmail account, and reading or sending e-mails from a script or creating a guest book for your web application.

Chapter 6, Screen-scraping and Other Practical Applications, introduces you to various third-party Python libraries that do some practical tasks, for example, locating companies on Google maps, grabbing information from Wikipedia, searching code repository on GitHub, or reading news from the BBC.

Chapter 7, Programming Across Machine Boundaries, gives you a taste of automating your system administration and deployment tasks over SSH. You can run commands, install packages, or set up new websites remotely from your laptop.

Chapter 8, Working with Web Services – XML-RPC, SOAP, and REST, introduces you to various API protocols such as XML-RPC, SOAP, and REST. You can programmatically ask any website or web service for information and interact with them. For example, you can search for products on Amazon or Google.

Chapter 9, Network Monitoring and Security, introduces you to various techniques for capturing, storing, analyzing, and manipulating network packets. This encourages you to go further to investigate your network security issues using concise Python scripts.

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 supplementary material for developing hands-on skills in any academic course on network programming.
Share This