0% found this document useful (0 votes)
51 views2 pages

Talking Raspberries, TCP Socket Protocol in Phyton

Raspberry Pi TCP socket protocol allows for fast and lightweight communication between devices over a network using Python. It involves installing the socket library on both the client and host devices, then writing a simple client-host script using sockets to open a connection and pass commands. While not as advanced as messaging apps, it is useful for exploring communication between devices like Raspberry Pis with some limitations such as requiring an open host connection and unique port per client connection.

Uploaded by

Mariimar Ponce
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views2 pages

Talking Raspberries, TCP Socket Protocol in Phyton

Raspberry Pi TCP socket protocol allows for fast and lightweight communication between devices over a network using Python. It involves installing the socket library on both the client and host devices, then writing a simple client-host script using sockets to open a connection and pass commands. While not as advanced as messaging apps, it is useful for exploring communication between devices like Raspberry Pis with some limitations such as requiring an open host connection and unique port per client connection.

Uploaded by

Mariimar Ponce
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Talking Raspberries, TCP socket protocol in Phyton

Majority of my communication is handled via AutoRemote. It links my pc,


mobile, tablet and Raspberry PI 2 & 3. Its all good and dandy most of
the times, until I try to issue a python command to the other RPI. Turns
out Raspberry PI TCP socket protocol in python can candle client-host
communication well. Socket in python is one of the low-level protocols
allowing passing over simple commands between 2 devices over the
internet. Communication is very fast, and script handling it is very
lightweight.

Raspberry Pi TCP Socket protocol


Before we can use socket with python, we need to install this library on
both devices (client and host) to do so simply run this in terminal:

1 sudo apt-get install socket


After prompt installation you will be able to use socket libraries within
your python scripts. Below you can see the sample code that you can
use in your creation. More details on the structure of the code in the
video.

As you can see from the example below, nothing stops you from writing
a simple chat protocol between both devices. Surely it wont be a
Whatsapp competitor, but it is something to explore for sure. Few things
to remember:

Host connection has to be open, otherwise client will throw an


exception
Port is linked to specific client and connection, you wont be able to
share the connection with other devices
If one of the sides terminates, connection is lost and new Host
session needs to be started
If you can live with these limitations, Raspberry Pi TCP socket provides
you with lightning fast responsiveness. How would you use Raspberry Pi
socket protocol?

You might also like