import socketserver
class MySocket(socketserver.StreamRequestHandler):
def handle(self):
conn = self.request
add = self.client_address
while True:
accept_data = str(conn.recv(1024), encoding='utf-8')
print(accept_data)
send_data = bytes(input(">>>>>"), encoding="utf8")
conn.sendall(send_data)
if __name__ == '__main__':
sever = socketserver.ThreadingTCPServer(('127.0.0.1', 8888), MySocket)
sever.serve_forever()
import socket
sock=socket.socket()
sock.connect(('127.0.0.1',8888))
while True:
sock.sendall(bytes('456',encoding="utf8"))
accept_data=str(sock.recv(1024),encoding="utf8")
print(accept_data)