Skip to content

Instantly share code, notes, and snippets.

@matancev
Created October 28, 2013 17:35
Show Gist options
  • Select an option

  • Save matancev/7201120 to your computer and use it in GitHub Desktop.

Select an option

Save matancev/7201120 to your computer and use it in GitHub Desktop.
import socket
port = 8303
sock = socket.socket()
sock.bind(("", port))
print("-----------------------------")
print(" Listening to port " + str(port) + "...")
print("-----------------------------")
print()
print("Hostname: " + socket.gethostname())
print()
while True:
sock.listen(1)
conn, addr = sock.accept()
print("[" + addr[0] + "] ", end="")
while True:
data = conn.recv(512)
if not data: break
print(bytes.decode(data), end="")
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment