Skip to content

Instantly share code, notes, and snippets.

@donalmacc
Created July 20, 2012 00:36
Show Gist options
  • Save donalmacc/3147924 to your computer and use it in GitHub Desktop.
Save donalmacc/3147924 to your computer and use it in GitHub Desktop.
Listener
import socket
#Create the socket connection
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 1756)) # Bind the connection
s.listen(1) # Listen for the connection. Will not advance unless a connection is received
conn, addr = s.accept() # Accepts a connection
print "Listening..." # Debug
while 1:
data = conn.recv(1024) # Receive transmission
# If Receiving anything, then print it out, otherwise just exit
if not data:
break
print "Received: ", (data)
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment