Foundations of Python Network Programming
Chapter 2 ■ UDp 33 if not hasattr(IN, 'IP_MTU'): raise RuntimeError('cannot perform MTU discovery on this combination' ' of oper ...
Chapter 2 ■ UDp 34 When setting socket options, you first have to name the option group in which they live and then, as a subseq ...
Chapter 2 ■ UDp 35 def server(interface, port): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((interface, po ...
Chapter 2 ■ UDp 36 But when you use the local network’s broadcast address, suddenly you will see that all of the broadcast serve ...
Chapter 2 ■ UDp 37 The server needs to bind() to an address and port before it can receive incoming packets. Client UDP programs ...
39 Chapter 3 TCP The Transmission Control Protocol (officially TCP/IP but referred to as TCP throughout the rest of this book) i ...
Chapter 3 ■ tCp 40 • The initial sequence number, in good TCP implementations, is chosen randomly so that villains cannot ass ...
Chapter 3 ■ tCp 41 One question to ask, though, is whether a client might want to open a TCP connection and then use it over sev ...
Chapter 3 ■ tCp 42 Note that while a passive socket is made unique by the interface address and port number at which it is liste ...
Chapter 3 ■ tCp 43 def client(host, port): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) p ...
Chapter 3 ■ tCp 44 Second, you will see that this TCP client is in one way much simpler than the UDP client, because it does not ...
Chapter 3 ■ tCp 45 Unfortunately, no equivalent Standard Library wrapper is provided for the recv() call, even though it suffers ...
Chapter 3 ■ tCp 46 $ python tcp_sixteen.py server "" Listening at ('0.0.0.0', 1060) Waiting to accept a new connection We have a ...
Chapter 3 ■ tCp 47 But you will see a big difference if you bring up the server, run the client against it, and then try killing ...
Chapter 3 ■ tCp 48 You can verify this by running Listing 3-1 in server mode, as shown previously, and trying to connect with a ...
Chapter 3 ■ tCp 49 This limitation will generally not trouble you if you follow the client-server pattern shown in Listing 3-1, ...
Chapter 3 ■ tCp 50 sent = 0 while sent < bytecount: sock.sendall(message) sent += len(message) print('\r %d bytes sent' % (se ...
Chapter 3 ■ tCp 51 Processing text while splitting on fixed-length blocks would also not work for UTF-8 encoded Unicode data, si ...
Chapter 3 ■ tCp 52 client grinds to a halt soon afterward. The amount of data processed before they seize up varies on the Ubunt ...
Chapter 3 ■ tCp 53 But how, then, are network clients and servers supposed to process large amounts of data without entering dea ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf