Last active
May 8, 2017 08:52
-
-
Save hightemp/7eaf2c74e7db05bbcf447a6eb5872ea1 to your computer and use it in GitHub Desktop.
[Python] [Socket] [Thread] Example of thread socket server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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