Book description
This book gives you everything you need to know about network programming using Python 3, the latest version of the Python language. It will benefit both scripters and serious application developers who want a feature-rich, yet simple language. Fully updated, this second edition includes all the new developments in network programming such as WSGI, FastCGI, and asynchronous communication.
Foundations of Python 3 Network Programming, Second Edition explains multitasking network servers using several models, including forking, threading, and non-blocking sockets. Extensive examples throughout the book demonstrate important concepts and practices, and provide a cadre of fully-functioning stand alone programs. Readers may even use the examples included as building blocks to create their own software.
Table of contents
- Copyright
- About the Authors
- About the Technical Reviewer
- Acknowledgements
- Introduction
- 1. Introduction to Client/Server Networking
-
2. UDP
- 2.1. Should You Read This Chapter?
- 2.2. Addresses and Port Numbers
- 2.3. Port Number Ranges
- 2.4. Sockets
- 2.5. Unreliability, Backoff, Blocking, Timeouts
- 2.6. Connecting UDP Sockets
- 2.7. Request IDs: A Good Idea
- 2.8. Binding to Interfaces
- 2.9. UDP Fragmentation
- 2.10. Socket Options
- 2.11. Broadcast
- 2.12. When to Use UDP
- 2.13. Summary
-
3. TCP
- 3.1. How TCP Works
- 3.2. When to Use TCP
- 3.3. What TCP Sockets Mean
- 3.4. A Simple TCP Client and Server
- 3.5. One Socket per Conversation
- 3.6. Address Already in Use
- 3.7. Binding to Interfaces
- 3.8. Deadlock
- 3.9. Closed Connections, Half-Open Connections
- 3.10. Using TCP Streams like Files
- 3.11. Summary
-
4. Socket Names and DNS
- 4.1. Hostnames and Domain Names
- 4.2. Socket Names
- 4.3. Five Socket Coordinates
- 4.4. IPv6
- 4.5. Modern Address Resolution
- 4.6. Asking getaddrinfo() Where to Bind
- 4.7. Asking getaddrinfo() About Services
- 4.8. Asking getaddrinfo() for Pretty Hostnames
- 4.9. Other getaddrinfo() Flags
- 4.10. Primitive Name Service Routines
- 4.11. Using getsockaddr() in Your Own Code
- 4.12. Better Living Through Paranoia
- 4.13. A Sketch of How DNS Works
- 4.14. Why Not to Use DNS
- 4.15. Why to Use DNS
- 4.16. Resolving Mail Domains
- 4.17. Zeroconf and Dynamic DNS
- 4.18. Summary
- 5. Network Data and Network Errors
- 6. TLS and SSL
-
7. Server Architecture
- 7.1. Daemons and Logging
- 7.2. Our Example: Sir Launcelot
- 7.3. An Elementary Client
- 7.4. The Waiting Game
- 7.5. Running a Benchmark
- 7.6. Event-Driven Servers
- 7.7. Poll vs. Select
- 7.8. The Semantics of Non-blocking
- 7.9. Event-Driven Servers Are Blocking and Synchronous
- 7.10. Twisted Python
- 7.11. Load Balancing and Proxies
- 7.12. Threading and Multi-processing
- 7.13. Threading and Multi-processing Frameworks
- 7.14. Process and Thread Coordination
- 7.15. Running Inside inetd
- 7.16. Summary
- 8. Caches, Message Queues, and Map-Reduce
-
9. HTTP
- 9.1. URL Anatomy
- 9.2. Relative URLs
- 9.3. Instrumenting urllib2
- 9.4. The GET Method
- 9.5. The Host Header
- 9.6. Codes, Errors, and Redirection
- 9.7. Payloads and Persistent Connections
- 9.8. POST And Forms
- 9.9. Successful Form POSTs Should Always Redirect
- 9.10. POST And APIs
- 9.11. REST And More HTTP Methods
- 9.12. Identifying User Agents and Web Servers
- 9.13. Content Type Negotiation
- 9.14. Compression
- 9.15. HTTP Caching
- 9.16. The HEAD Method
- 9.17. HTTPS Encryption
- 9.18. HTTP Authentication
- 9.19. Cookies
- 9.20. HTTP Session Hijacking
- 9.21. Cross-Site Scripting Attacks
- 9.22. WebOb
- 9.23. Summary
- 10. Screen Scraping
- 11. Web Applications
-
12. E-mail Composition and Decoding
- 12.1. E-mail Messages
- 12.2. Composing Traditional Messages
- 12.3. Parsing Traditional Messages
- 12.4. Parsing Dates
- 12.5. Understanding MIME
- 12.6. How MIME Works
- 12.7. Composing MIME Attachments
- 12.8. MIME Alternative Parts
- 12.9. Composing Non-English Headers
- 12.10. Composing Nested Multiparts
- 12.11. Parsing MIME Messages
- 12.12. Decoding Headers
- 12.13. Summary
-
13. SMTP
- 13.1. E-mail Clients, Webmail Services
- 13.2. How SMTP Is Used
- 13.3. Sending E-Mail
- 13.4. Headers and the Envelope Recipient
- 13.5. Multiple Hops
- 13.6. Introducing the SMTP Library
- 13.7. Error Handling and Conversation Debugging
- 13.8. Getting Information from EHLO
- 13.9. Using Secure Sockets Layer and Transport Layer Security
- 13.10. Authenticated SMTP
- 13.11. SMTP Tips
- 13.12. Summary
- 14. POP
-
15. IMAP
- 15.1. Understanding IMAP in Python
- 15.2. IMAPClient
- 15.3. Examining Folders
- 15.4. Message Numbers vs. UIDs
- 15.5. Message Ranges
- 15.6. Summary Information
- 15.7. Downloading an Entire Mailbox
- 15.8. Downloading Messages Individually
- 15.9. Flagging and Deleting Messages
- 15.10. Deleting Messages
- 15.11. Searching
- 15.12. Manipulating Folders and Messages
- 15.13. Asynchrony
- 15.14. Summary
-
16. Telnet and SSH
- 16.1. Command-Line Automation
- 16.2. Command-Line Expansion and Quoting
- 16.3. Unix Has No Special Characters
- 16.4. Quoting Characters for Protection
- 16.5. The Terrible Windows Command Line
- 16.6. Things Are Different in a Terminal
- 16.7. Terminals Do Buffering
- 16.8. Telnet
- 16.9. SSH: The Secure Shell
- 16.10. An Overview of SSH
- 16.11. SSH Host Keys
- 16.12. SSH Authentication
- 16.13. Shell Sessions and Individual Commands
- 16.14. SFTP: File Transfer Over SSH
- 16.15. Other Features
- 16.16. Summary
-
17. FTP
- 17.1. What to Use Instead of FTP
- 17.2. Communication Channels
- 17.3. Using FTP in Python
- 17.4. ASCII and Binary Files
- 17.5. Advanced Binary Downloading
- 17.6. Uploading Data
- 17.7. Advanced Binary Uploading
- 17.8. Handling Errors
- 17.9. Detecting Directories and Recursive Download
- 17.10. Creating Directories, Deleting Things
- 17.11. Doing FTP Securely
- 17.12. Summary
- 18. RPC
Product information
- Title: Foundations of Python Network Programming: The comprehensive guide to building network applications with Python, Second Edition
- Author(s):
- Release date: December 2010
- Publisher(s): Apress
- ISBN: 9781430230038
You might also like
book
Foundations of Python Network Programming, Third Edition
Foundations of Python Network Programming, Third Edition, covers all of the classic topics found in the …
book
Python Network Programming
Power up your network applications with Python programming Key Features Master Python skills to develop powerful …
book
Mastering Python Networking - Third Edition
New edition of the bestselling guide to mastering Python Networking, updated to Python 3 and including …
book
Mastering Python Networking - Fourth Edition
Get to grips with the latest container examples, Python 3 features, GitLab DevOps, network data analysis, …