python gevent并发socket
import queue import gevent from gevent import monkey; monkey.patch_socket()#猴子补丁代替python原有的socket selector = selectors.DefaultSelector() socket_server = socket.socket() address_server = ('0.0.0.0',8080) socket_server.bind(address_server) socket_server.listen(1000) q = queue.Queue(3) def conmuer(connect): while True: massage = connect.recv(1024) if massage: print(massage) connect.send(massage) else: connect.close() break while True: connect, address = socket_server.accept() print(connect) gevent.spawn(conmuer, connect)#创建协程
相关推荐
efeve 2020-09-14
一叶梧桐 2020-10-14
lzzyok 2020-10-10
digwtx 2020-09-14
poplpsure 2020-08-17
ITxiaobaibai 2020-07-26
libowenhit 2020-07-23
luckykapok 2020-07-06
hongsheyoumo 2020-06-27
jannal 2020-06-21
lanmantech 2020-06-16
咻咻ing 2020-06-16
weibingbingnet 2020-06-14
woyanyouxin 2020-06-04
houjinkai 2020-06-03
txj 2020-06-02
Chydar 2020-05-15