Last active
December 29, 2021 16:53
-
-
Save arseniyturin/829e702cc52a78a6345e15000afab4cb to your computer and use it in GitHub Desktop.
This file contains 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
import socket | |
from threading import Thread | |
def server(host='', port=8000): | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) | |
sock.bind((host, port)) | |
sock.listen() | |
while True: | |
client, address = sock.accept() | |
Thread(target=handle_client, args=(address, client), daemon=True).start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment