Last active
August 29, 2015 14:04
-
-
Save donalmacc/1e645c29648fd68b521f to your computer and use it in GitHub Desktop.
simple printing server
This file contains hidden or 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
from socket import * | |
host = "localhost" | |
port = 50000 | |
buf = 1024 | |
addr = (host,port) | |
# Create socket and bind to address | |
UDPSock = socket(AF_INET,SOCK_DGRAM) | |
UDPSock.bind(addr) | |
print "Listening" | |
while 1: | |
data,addr = UDPSock.recvfrom(buf) | |
if not data: | |
print "Client has exited!" | |
break | |
else: | |
print data | |
# Close socket | |
UDPSock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment