Skip to content

Instantly share code, notes, and snippets.

@donalmacc
Last active August 29, 2015 14:04
Show Gist options
  • Save donalmacc/1e645c29648fd68b521f to your computer and use it in GitHub Desktop.
Save donalmacc/1e645c29648fd68b521f to your computer and use it in GitHub Desktop.
simple printing server
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