Foundations of Python Network Programming 3rd Edition Brandon Rhodes John Goerzeninstant download
Foundations of Python Network Programming 3rd Edition Brandon Rhodes John Goerzeninstant download
https://ebookmeta.com/product/foundations-of-python-network-
programming-3rd-edition-brandon-rhodes-john-goerzen/
Third Edition
Brandon Rhodes
John Goerzen
Foundations of Python Network Programming, Third Edition
Copyright © 2014 by Brandon Rhodes and John Goerzen
This work is subject to copyright. All rights are reserved by the Publisher,
whether the whole or part of the material is concerned, specifically the rights
of translation, reprinting, reuse of illustrations, recitation, broadcasting,
reproduction on microfilms or in any other physical way, and transmission or
information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Exempted from this legal reservation are brief excerpts in connection with
reviews or scholarly analysis or material supplied specifically for the purpose
of being entered and executed on a computer system, for exclusive use by
the purchaser of the work. Duplication of this publication or parts thereof is
permitted only under the provisions of the Copyright Law of the Publisher’s
location, in its current version, and permission for use must always be
obtained from Springer. Permissions for use may be obtained through
RightsLink at the Copyright Clearance Center. Violations are liable to
prosecution under the respective Copyright Law.
ISBN-13 (pbk): 978-1-4302-5854-4
ISBN-13 (electronic): 978-1-4302-5855-1
Trademarked names, logos, and images may appear in this book. Rather
than use a trademark symbol with every occurrence of a trademarked name,
logo, or image we use the names, logos, and images only in an editorial
fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and
similar terms, even if they are not identified as such, is not to be taken as an
expression of opinion as to whether or not they are subject to proprietary
rights.
While the advice and information in this book are believed to be true and
accurate at the date of publication, neither the authors nor the editors nor
the publisher can accept any legal responsibility for any errors or omissions
that may be made. The publisher makes no warranty, express or implied,
with respect to the material contained herein.
Managing Director: Welmoed Spahr
Publisher: Heinz Weinheimer
Lead Editor: Michelle Lowman
Technical Reviewers: Alexandre Beaulne and Peter Membrey
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham,
Gary Cornell, Louise Corrigan, Jim DeWolf, Jonathan Gennick,
Robert Hutchinson, Michelle Lowman, James Markham,
Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick,
Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt
Wade, Steve Weiss
Coordinating Editor: Kevin Walter
Developmental Editor: Gary Schwartz
Copy Editor: Kim Wimpsett
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media
New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-
SPRINGER, fax (201) 348-4505, e-mail [email protected],
or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance
Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit
www.apress.com.
Index
Contents
Binding to Interfaces
UDP Fragmentation
Socket Options
Broadcast
When to Use UDP
Summary
Chapter 3: TCP
How TCP Works
When to Use TCP
What TCP Sockets Mean
A Simple TCP Client and Server
One Socket per Conversation
Address Already in Use
Binding to Interfaces
Deadlock
Closed Connections, Half-Open Connections
Using TCP Streams Like Files
Summary
Chapter 4: Socket Names and DNS
Hostnames and Sockets
Five Socket Coordinates
IPv6
Summary
Chapter 5: Network Data and Network Errors
Bytes and Strings
Character Strings
Binary Numbers and Network Byte Order
Summary
Chapter 6: TLS/SSL
What TLS Fails to Protect
What Could Possibly Go Wrong?
Generating Certificates
Offloading TLS
Python 3.4 Default Contexts
Variations on Socket Wrapping
Async Servers
Callback-Style asyncio
Coroutine-Style asyncio
The Legacy Module asyncore
The Best of Both Worlds
Summary
Chapter 9: HTTP Clients
Python Client Libraries
Ports, Encryption, and Framing
Methods
Paths and Hosts
Status Codes
Caching and Validation
Content Encoding
Content Negotiation
Content Type
HTTP Authentication
Cookies
Connections, Keep-Alive, and httplib
Summary
Chapter 10: HTTP Servers
WSGI
Asynchronous Server-Frameworks
Forward and Reverse Proxies
Four Architectures
Running Python Under Apache
The Rise of Pure-Python HTTP Servers
The Benefits of Reverse Proxies
Platforms as a Service
GET and POST Patterns and the Question of REST
WSGI Without a Framework
Summary
Chapter 11: The World Wide Web
Hypermedia and URLs
Parsing and Building URLs
Relative URLs
The Hypertext Markup Language
Reading and Writing to a Database
A Terrible Web Application (in Flask)
The Dance of Forms and HTTP Methods
When Forms Use Wrong Methods
Safe and Unsafe Cookies
Nonpersistent Cross-Site Scripting
Persistent Cross-Site Scripting
Cross-Site Request Forgery
The Improved Application
Summary
Chapter 12: Building and Parsing E-Mail
E-Mail Message Format
Building an E-Mail Message
Adding HTML and Multimedia
Adding Content
Parsing E-Mail Messages
Walking MIME Parts
Header Encodings
Parsing Dates
Summary
Chapter 13: SMTP
E-mail Clients vs. Webmail Services
In the Beginning Was the Command Line
The Rise of Clients
The Move to Webmail
TANDEM HARNESS.
BREAKING TO HARNESS.
“Another book which will appeal to all who are interested in horses is the capital
little volume called ‘Hints on Driving,’ by Capt. Morley Knight, R.A. Captain Knight
has nothing to do with history or anecdote; his work is entirely practical. Doubtless
there are other books on the subject, but none within our knowledge is more clear
or complete in the instructions given for driving in single or double harness, and,
above all, for the more difficult mysteries of four-in-hand or tandem driving. The
utility of the volume is much increased by the accurate vignette illustrations of
hands holding reins, etc., made by G. H. A. White, Royal Artillery.”
“Captain Knight is the author of a thoroughly practical book entitled ‘Hints on
Driving,’ which he dedicates to Major-General Albert Williams.”—Morning Post.
“There are perhaps few greater masters of the detail of the art than the
author.”—The Sportsman.
“One conspicuous and excellent feature is that it takes nothing for granted, etc.
Altogether this little volume is a capital manual of its kind.”—Glasgow Herald.
“It is simple, practical, and instructive. So far as the delicate art of handling the
ribbons can be taught by a book, this book succeeds to the best effect in teaching
it.”—Scotsman.
“Any who are deficient or novices in the art of driving—and it is an art—will do
well to inwardly digest the contents of a capital volume by Captain Knight, R. A.,
whose practical advice, down to the veriest minutiæ, will work wonders in a short
space.”—Sporting Life.
“Captain Knight has done as much as anyone could do to place before his
readers the more or less accepted canons of driving. The book costs but little
money, and anyone who wants to drive properly would do well to invest his 3s.
6d., and commit to memory some of the principal rules.”—The Field.
“A very businesslike and pleasant little book it is. Captain M. Knight’s little book
will be found far more serviceable than the big work on Driving in the ‘Badminton
Library.’ The book is provided with copious illustrations and diagrams.”—National
Observer.
“The advice and details afforded by Captain Knight are about as succinct, clear,
and reliable as those which any pupil can desire to acquire.”—The Road.
“We have come to the conclusion that the author has accomplished his design
with no little success, and that anyone who desires to drive properly would be well
advised to study Capt. Knight’s pages attentively before spending much money in
driving lessons.”—Baily’s Magazine.
“Much which it is very necessary for the learner to know may be acquired from a
writer who is sufficient master of his pen and of his subject to make his meaning
clear. Such an one is Captain C. Morley Knight, R.A., whose ‘Hints on Driving,’
published by Bell and Sons, will supply a long-felt want.”—Referee.
“The neophyte in handling the ribbons has found an excellent friend in Captain
C. M. Knight, R.A., whose ‘Hints on Driving’ are exactly what the beginner needs.
Capt. Knight is a master in the art, and whatever he says is the fruit of practical
experience.”—Army and Navy Gazette.
“Quite fulfils its author’s object,—namely, to explain to beginners the
rudimentary principles and niceties of driving.”—United Service Gazette.
“A most useful, practical, and handy little work on all that appertains to driving
in single and double harness—including four-in-hand and tandem driving.”—Broad
Arrow.
“We have not for some time come across such a thoroughly practical and sound
handbook as this.”—Admiralty and Horse Guards Gazette.
“This little octavo volume should have an immense sale in India, where every
household keeps its trap. Herein is given information and instruction on every
conceivable point connected with the mysterious craft of Whip and Reins.”—The
Pioneer (Allahabad).
“It is pleasant to meet with a little volume like Captain Knight’s ‘Hints on
Driving,’ so erudite and yet so simple.”—Times of India.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.