Foundations of Python Network Programming

(WallPaper) #1

async servers
asynchronous callback object, 133
BSD and Linux distributions, 133
bytes_to_send dictionary, 127
callback-Style asyncio, 128
coroutine-style asyncio, 130
legacy module asyncore, 131
POLLIN event, 128
poll()-powered loop, 125
poll(), recv(), send(), and close() system, 128
raw asynchronous event loop, 126
single client socket, 125
sockets dictionary, 127
get_answer() function, 118
handle_conversation(), 119
handle_request(), 119
load balancer, 115
minimalist style, 116
multiprocess servers
accept() statement, 123
advantage, 123
disadvantage, 123
multithreaded server, 123
socketserver module, 124
Standard Library server, 124
threading and multiprocessing modules, 124
old-fashioned technique, 116
one or more client connections, 134
parse_command_line() function, 119
Python community, 116
recv_until(), 119
single client, 134
single machine, 115
single-threaded server
denial-of-service attack, 121
-h and-p help option, 121
Python interprets, 121
recv() calls, 123
recv() returns, 123
sample run, 122
standard local host IP address, 121
trace module, 122
weakness of, 121
TCP load balancer, 116
Toy Zen-of-Python Protocol, 117
The Twelve-Factor App, 116
Zen-of-Python Protocol, 119
set_cipher() method, 112
setsockopt() method, 34
shutdown() call, 53
Simple Mail Transport Protocol (SMTP), 223
authentication, 256
client e-mail program, 244


EHLO command, 252
e-mail clients
command line, 241
users interface, 242
vs. webmail, 243
error handling and debugging, 249
headers and envelope recipients, 246
implementation, 258
internet e-mail servers, 245
library, 248
multiple hops, 247
Python-driven SMTP session, 245
sending e-mail, 246
SPF, 245
SSL/TLS, 254
SMTP. See Simple Mail Transport Protocol (SMTP)
SMTP_SSL object, 106
Sockets
bind() command, 21
blocking, 26
client code, 20, 22
clients and unwelcome replies, 23
connection, 28
coordination, 58
creation, 21
daemon program, 28
exponential backoff, 26
getaddrinfo() function
AF_INET, 61
bind(), 61
canonical hostname, 63
connect()/sendto() service, 62
create and connect, 65
flags, 64
“pretty print” module, 60
primitive name service routines, 65
SOCK_DGRAM socket, 61
SOCK_STREAM socket, 61
getsockname() method, 22
host names
mysocket.accept(), 58
mysocket.bind, 58
mysocket.connect, 58
mysocket.getpeername(), 58
mysocket.getsockname(), 58
mysocket.recvfrom(.. .), 58
mysocket.sendto, 58
TLD, 57
IPv6, 59
loopback interface, 20
object-based interface, 19
options
getattr() function, 34
POSIX socket interface, 33

■ index


354


Server architecture (cont.)

Free download pdf