1 将下面代码拷贝到一个文件,命名为asyncore.py
复制代码 代码如下:
import socket
import select
import sys
def ds_asyncore(addr,callback,timeout=5):
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(addr)
r,w,e = select.select([s],[],[],timeout)
if r:
respose_data=s.recv(1024)
callback(respose_data)
s.close()
return 0
else:
s.close()
return 1
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8