待實驗的socketserver
阿新 • • 發佈:2017-08-31
nis read port imp mat quest ddr main odi
# -*- coding:utf-8 -*-
# Author: Dennis Huang
__Author__ = "Dennis"
import socketserver
class MyTCPHandler(socketserver.BaseRequestHandler)
def handle(self):
"""
所有請求在這裏處理
"""
self.data = self.request.recv(1024).strip()
print("{} wrote:".format(self.client_address[0]))
print(self.data)
self.request.send(self.data.upper())
if __name__ == "__main__":
HOST,PORT = "localhost",9999
server = socketserver.ThreadingTCPServer((HOST,PORT),MyTCPHandler)
server.serve_forever()
待實驗的socketserver