Created
July 20, 2012 00:36
-
-
Save donalmacc/3147924 to your computer and use it in GitHub Desktop.
Listener
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
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