Skip to content

Instantly share code, notes, and snippets.

@hightemp
Last active May 8, 2017 08:52
Show Gist options
  • Save hightemp/7eaf2c74e7db05bbcf447a6eb5872ea1 to your computer and use it in GitHub Desktop.
Save hightemp/7eaf2c74e7db05bbcf447a6eb5872ea1 to your computer and use it in GitHub Desktop.
[Python] [Socket] [Thread] Example of thread socket server
def fnServer(port):
s = socket.socket()
s.bind(('0.0.0.0', port))
s.listen(500)
while True:
cli, addr = s.accept()
t = threading.Thread(target=handle_request, args=(cli, time.sleep))
t.daemon = True
t.start()
fnServer(8090)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment