Created
August 30, 2018 11:53
-
-
Save shubham7298/95a1761c2afa95a13d8c9944b114d5a6 to your computer and use it in GitHub Desktop.
Socket Programming in Python(server)
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
# Save as server.py | |
# Message Receiver | |
import os | |
from socket import * | |
host = "" | |
port = 13000 | |
buf = 1024 | |
addr = (host, port) | |
UDPSock = socket(AF_INET, SOCK_DGRAM) | |
UDPSock.bind(addr) | |
print "Waiting to receive messages..." | |
while True: | |
(data, addr) = UDPSock.recvfrom(buf) | |
print "Received message: " + data | |
if data == "exit": | |
break | |
UDPSock.close() | |
os._exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment