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

Handling data on persistent connections


A new problem which our persistent connection approach raises is that we can no longer assume that our socket.recv() call will contain data from only one message. In our echo server, because of how we have defined the protocol, we know that as soon as we see a null byte, the message that we have received is complete, and that the sender won't be sending anything further. That is, everything we read in the last socket.recv() call is a part of that message.

In our new setup, we'll be reusing the same connection to send an indefinite number of messages, and these won't be synchronized with the chunks of data that we will pull from each socket.recv(). Hence, it's quite possible that the data from one recv() call will contain data from multiple messages. For example, if we send the following:

caerphilly,
illchester,
brie

Then on the wire they will look like this:

caerphilly\0illchester\0brie\0

Due to the vagaries of network transmission though, a set of successive...

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