Skip to content

Instantly share code, notes, and snippets.

@Merwanski
Created November 24, 2021 13:39
Show Gist options
  • Save Merwanski/270d1a9b805b5f6eaf0c24f781366568 to your computer and use it in GitHub Desktop.
Save Merwanski/270d1a9b805b5f6eaf0c24f781366568 to your computer and use it in GitHub Desktop.
server.py
#!/usr/bin/env python3
from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
import sys
PORT_NUMBER = 5000
SIZE = 1024
hostName = gethostbyname( '0.0.0.0' )
mySocket = socket( AF_INET, SOCK_DGRAM )
mySocket.bind( (hostName, PORT_NUMBER) )
print ("Test server listening on port {0}\n".format(PORT_NUMBER))
while True:
(data,addr) = mySocket.recvfrom(SIZE)
print(data, addr)
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment