|
client.send(buffer.encode('utf-8')) |
Description
An exception occurs in chapter02/bhnet.py in the function client_sender on the second call to client.send() in the sender while-loop. The exception due to a broken pipe.
Reproduction Steps
The bug was found by running chapter02/tcp-server.py and connecting to it with chapter02/bhnet.py:
$ python3 ./bhpnet.py -t 127.0.0.1 -p 9999
Hallo [Ctrl-D]
ACK! Test1
Test2
[*] Exception! Exiting.
[*] Caught exception socket.error: [Errno 32] Broken pipe
On the server side:
$ python3 ./tcp-server.py
[*] Listening on 0.0.0.0:9999
[*] Accepted connection from: 127.0.0.1:50890
[*] Received: b'Hallo\n'
('127.0.0.1', 50890)
Note that the outer while-loop (line 128 - 148) is run through twice after the initial successful sending of the buffer to the server but without ever sending data again. The expected behavior is that "Test1" would be sent to the server at the end of one loop cycle and "Test2" would be sent at the end of the next loop cycle. However, the server never receives even "Test1".