网络编程~~~~socketserver服务端
socketserver服务端
import socketserver
class MyServer(socketserver.BaseRequestHandler):
def handle(self):
while 1:
from_client_msg = self.request.recv(1024)
print(from_client_msg.decode('utf-8'))
to_client_msg = input('>>>').encode('utf-8')
self.request.send(to_client_msg)
if __name__ == '__main__':
server = socketserver.ThreadingTCPServer(('127.0.0.1',8848),MyServer)
server.serve_forever()