Created
November 24, 2021 13:39
-
-
Save Merwanski/270d1a9b805b5f6eaf0c24f781366568 to your computer and use it in GitHub Desktop.
server.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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