import socket HOST = '127.0.0.1' # The server's hostname or IP address PORT = 4242 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: s.bind(('', 10000)) while True: msg, addr = s.recvfrom(8192) # This is the amount of bytes to read at maximum print("Got message from %s: %s" % (addr, msg ))