Skip to content

Instantly share code, notes, and snippets.

@0x9090
Last active April 12, 2017 09:05
Show Gist options
  • Save 0x9090/a7aba0778a3ae3fc35f738bcecdecaf2 to your computer and use it in GitHub Desktop.
Save 0x9090/a7aba0778a3ae3fc35f738bcecdecaf2 to your computer and use it in GitHub Desktop.
Simple Socket Listener
#!/usr/bin/env python
import socket, sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 6675
server_address = ("0.0.0.0", port)
sock.bind(server_address)
sock.listen(1)
while True:
print "~ Waiting For Connection on port:", port
connection, client_address = sock.accept()
try:
print "~ Connection From:", client_address[0]
while True:
data = connection.recv(16)
print "%s" % data
if data:
print "~ Recieved Data"
connection.sendall("1")
else:
print "~ No More Data From:", client_address[0]
break
finally:
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment