Concurrent I/O

If you're adventurous, then you may have tried connecting to our server using more than one client at once. If you tried sending messages from both of them, then you'd have seen that it does not work as we might have hoped. If you haven't tried this, then give it a go.

A working echo session on the client should look like this:

Type message, enter to send. 'q' to quit
hello world
Sent message: hello world
Received echo: hello world
Closed connection to server

However, when trying to send a message by using a second connected client, we'll see something like this:

Type message, enter to send. 'q' to quit
hello world
Sent message: hello world

The client will hang when the message is sent, and it won't get an echo reply. You may also ...

Get Learning Python Network Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.