Skip to content
Snippets Groups Projects
Commit f6402114 authored by Elias Maurer's avatar Elias Maurer
Browse files

Add new file

parent c9282937
No related branches found
No related tags found
No related merge requests found
#source: https://www.dropbox.com/scl/fi/ro661g8c3a1g8r9aphiax/client.py?rlkey=ti9hkq56ja3qw1p78erfq83k5&e=1&dl=0
#from: Culbertson, Cory (2022) Client-Server Communication with Two Raspberry Pies and Python, https://www.youtube.com/watch?v=T3XOac7QmAI
import socket
host = "0.0.0.0"
port = 5111
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #avoid reuse error msg
s.bind((host,port))
print ("Server started. Waiting for connection...")
s.listen()
c, addr = s.accept()
print ("Connection from: ",addr)
while True:
#data is in bytes format, use decode() to transform it into a string
data = c.recv(1024)
if not data:
break
value = data.decode()
print ("Received: ",value)
print ("Disconnected. Exiting.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment