Table of Contents
- Chapter 1: Network Programming and Python Preface vii
- An introduction to TCP/IP networks
- IP addresses
- Network interfaces
- Assigning IP addresses
- IP addresses on the Internet
- Packets
- Networks
- Routing with IP
- DNS
- The protocol stack or why the Internet is like a cake
- Layer 4 – TCP and UDP
- Network ports
- UDP
- TCP
- UDP versus TCP
- Layer 5 – The application layer
- On to Python!
- Network programming with Python
- Breaking a few eggs
- Taking it from the top
- Downloading an RFC
- Looking deeper
- Programming for TCP/IP networks
- Firewalls
- Network Address Translation
- IPv6
- Summary
- An introduction to TCP/IP networks
- Chapter 2: HTTP and Working with the Web [ ii ]
- Request and response
- Requests with urllib
- Response objects
- Status codes
- Handling problems
- HTTP headers
- Customizing requests
- Content compression
- Multiple values
- Content negotiation
- Content types
- User agents
- Cookies
- Cookie handling
- Know your cookies
- Redirects
- URLs
- Paths and relative URLs
- Query strings
- URL encoding
- URLs in summary
- HTTP methods
- The HEAD method
- The POST method
- Formal inspection
- HTTPS
- The Requests library
- Handling errors with Requests
- Summary
- Chapter 3: APIs in Action
- Getting started with XML
- The XML APIs
- The basics of ElementTree
- Pretty printing
- Element attributes
- Converting to text
- The Amazon S3 API
- Registering with AWS
- Authentication
- Setting up an AWS user
- Regions [ iii ]
- S3 buckets and objects
- An S3 command-line client
- Creating a bucket with the API
- Uploading a file
- Retrieving an uploaded file through a web browser
- Displaying an uploaded file in a web browser
- Downloading a file with the API
- Parsing XML and handling errors
- Parsing XML
- Finding elements
- Handling errors
- Further enhancements
- The Boto package
- Wrapping up with S3
- Getting started with XML
- JSON
- Encoding and decoding
- Using dicts with JSON
- Other object types
- The Twitter API
- A Twitter world clock
- Authentication for Twitter
- Registering your application for the Twitter API
- Authenticating requests
- A Twitter client
- Polling for Tweets
- Processing the Tweets
- Rate limits
- Sending a reply
- Final touches
- Taking it further
- Polling and the Twitter streaming APIs
- Alternative oAuth flows
- HTML and screen scraping
- HTML parsers
- Show me the data
- Parsing HTML with lxml
- Zeroing in
- Searching with XPath
- XPath conditions
- Pulling it together
- With great power...
- Choosing a User Agent
- The Robots.txt file [ iv ]
- Summary
- Choosing a User Agent
- Chapter 4: Engaging with E-mails
- E-mail terminologies
- Sending e-mails with SMTP
- Composing an e-mail message
- Sending an e-mail message
- Sending e-mails securely with TLS
- Retrieving e-mails by using POP3 with poplib
- Retrieving e-mails by using IMAP with imaplib
- Sending e-mail attachments
- Sending e-mails via the logging module
- Summary
- Chapter 5: Interacting with Remote Systems
- Secure shell – access using Python
- Inspecting the SSH packets
- Transferring files through SFTP
- Transferring files with FTP
- Inspecting FTP packets
- Fetching Simple Network Management Protocol data
- Inspecting SNMP packets
- Reading Light-weight Directory Access Protocol data
- Inspecting LDAP packets
- Sharing files with SAMBA
- Inspecting SAMBA packets
- Summary
- Secure shell – access using Python
- Chapter 6: IP and DNS
- Retrieving the network configuration of a local machine
- Manipulating IP addresses
- IP network objects
- Network interface objects
- The IP address objects
- Planning IP addresses for your local area network
- GeoIP look-ups
- DNS look-ups
- Inspecting DNS client/server communication
- NTP clients
- Inspecting the NTP client/server communication
- Summary
- Chapter 7: Programming with Sockets [ v ]
- Basics of sockets
- Working with TCP sockets
- Inspecting the client/server communication
- TCP servers
- Inspecting client/server interaction
- Working with UDP sockets
- TCP port forwarding
- A non-blocking socket I/O
- Securing sockets with TLS/SSL
- Inspecting standard SSL client/server communication
- Creating a custom SSL client/server
- Inspecting interaction between a custom SSL client/server
- Summary
- Chapter 8: Client and Server Applications
- Client and server
- An echo protocol
- Framing
- A simple echo server
- Handling the received data
- The server itself
- A simple echo client
- Concurrent I/O
- Multithreading and multiprocessing
- Threading and the GIL
- A multithreaded echo server
- Designing a chat server
- A chat protocol
- Handling data on persistent connections
- A multithreaded chat server
- Queues
- Locks
- A multithreaded chat client
- Event-driven servers
- A low-level event-driven chat server
- Frameworks
- An eventlet-based chat server
- An asyncio-based chat server
- More on frameworks [ vi ]
- Taking our servers forward
- Summary
- Chapter 9: Applications for the Web
- What's in a web server?
- Python and the Web
- Web frameworks
- Flask – a microframework
- Templating
- Other templating engines
- Adding some style
- A note on security
- XSS
- CSRF
- Finishing up with frameworks
- Hosting Python web applications
- CGI
- Recycling for a better world
- Event-driven servers
- WSGI
- Hosting in practice
- Summary
- Appendix: Working with Wireshark
- Packet sniffers
- Wireshark
- Installation
- Capturing some packets
- Filtering
- Inspecting packets
- A versatile tool
- Index