Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Learning Python Networking
  • Toc
  • feedback
Learning Python Networking

Learning Python Networking

By : Dr. M. O. Faruque Sarker, Samuel B Washington, Sam Washington
3.7 (7)
close
Learning Python Networking

Learning Python Networking

3.7 (7)
By: Dr. M. O. Faruque Sarker, Samuel B Washington, Sam Washington

Overview of this book

If you're a Python developer or a system administrator with Python experience and you're looking to take your first steps in network programming, then this book is for you. Basic knowledge of Python is assumed.
Table of Contents (12 chapters)
close
10
A. Working with Wireshark
11
Index

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 the connected clients. As we are using multiple threads to handle our clients, this means that we need to set up communication between the threads. With this, we're dipping our toe into the world of concurrent programming, and it should be...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete