Skip to content

Instantly share code, notes, and snippets.

@Yoiter
Last active December 8, 2017 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yoiter/f7d855772eefa23d52af5f5a8e50f842 to your computer and use it in GitHub Desktop.
Save Yoiter/f7d855772eefa23d52af5f5a8e50f842 to your computer and use it in GitHub Desktop.
import socket
s = socket.socket()
host = '127.0.0.1'
port = 50004
s.bind((host, port))
s.listen(5)
conn = None
word = input("Hangman word:" )
while True:
if conn is None:
print("[Waiting for connection...]")
conn, addr = s.accept()
print("Got connected from", addr)
else:
conn.send(word.encode('UTF-8'))
print("[Waiting for results...]")
print(str(conn.recv(1024).decode('UTF-8')))
if str(conn.recv(1024).decode('UTF-8')) == "Please send hint":
hint = input("hint: ")
sendhint = str("hint: " + hint)
conn.send(hint.encode('UTF-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment