标签:bsp utf-8 继承 bytes and thread col import dal
python2.X中socket是不能实现并发的
所以就有了socketserver
语法如下:
import socketserver class MyServer(socketserver.BaseRequestHandler): #必须继承BaseRequestHandler def handle(self): #方法名必须用handle conn = self.request conn.sendall(bytes(‘aaaa‘,encoding=‘utf-8‘)) if __name__ == ‘__main__‘: server = socketserver.ThreadingTCPServer((‘127.0.0.1‘,8008),MyServer) server.serve_forever()
客户端同socket语法
标签:bsp utf-8 继承 bytes and thread col import dal
原文地址:http://www.cnblogs.com/yxi-liu/p/7647216.html