24 lines
504 B
Python
24 lines
504 B
Python
import socketserver
|
|
|
|
|
|
PORT = 1337
|
|
|
|
|
|
class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
|
def handle(self):
|
|
"""Echo"""
|
|
data = self.request.recv(1024)
|
|
print(data)
|
|
self.request.sendall(data)
|
|
|
|
|
|
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
|
pass
|
|
|
|
|
|
with ThreadedTCPServer(("0.0.0.0", PORT), ThreadedTCPRequestHandler) as server:
|
|
try:
|
|
server.serve_forever()
|
|
except KeyboardInterrupt:
|
|
server.shutdown()
|