# -*- 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()
原文:http://www.cnblogs.com/dennnnnis/p/7455780.html