Skip to content

Instantly share code, notes, and snippets.

@Bogdanp
Created October 17, 2018 05:37
Show Gist options
  • Save Bogdanp/a21d9257accd7bcb78cae05212b00719 to your computer and use it in GitHub Desktop.
Save Bogdanp/a21d9257accd7bcb78cae05212b00719 to your computer and use it in GitHub Desktop.
with socket.socket() as server_sock:
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_sock.bind((HOST, PORT))
server_sock.listen(0)
print(f"Listening on {HOST}:{PORT}...")
client_sock, client_addr = server_sock.accept()
print(f"New connection from {client_addr}.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment