Python操作多线程之socket【多测师】
#_*_coding:utf-8_*_ #!/usr/bin/env python import multiprocessing import threading import socket # 多线程并发的socket服务端 s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind(('127.0.0.2',8080)) s.listen(5) def action(conn): while True: data=conn.recv(1024) print(data) conn.send(data.upper()) if __name__ == '__main__': while True: conn,addr=s.accept() p=threading.Thread(target=action,args=(conn,)) p.start()