Designing a chat server
We've got a working echo server and it can handle multiple clients simultaneously, so we're pretty close to having a functional chat client. However, our server needs to broadcast the messages it receives to all the connected clients. Sounds simple, but there are two problems that we need to overcome to make this happen.
First, our protocol needs an overhaul. If we think about what needs to happen from a client's point of view, then we can no longer rely on the simple work flow:
client connect > client send > server send > client disconnect.
Clients can now potentially receive messages at any time, and not just when they send a message to the server themselves.
Second, we need to modify our server to send messages to all of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access