python实现Linux异步epoll代码
程序员文章站
2023-08-16 17:12:42
复制代码 代码如下:import socketimport select
if __name__=="__main__": s=soc...
复制代码 代码如下:
import socket
import select
if __name__=="__main__":
s=socket.socket(socket.af_inet,socket.sock_stream)
s.setsockopt(socket.sol_socket,socket.so_reuseaddr,1)
s.bind(("",20123))
s.listen(10)
epoll=select.epoll()
print s.fileno()
print select.epollin|select.epollet
epoll.register(s.fileno(),select.epollin|select.epollet)
while 1:
epoll_list=epoll.poll()
for fd,events in epoll_list:
print fd
print events
if fd==s.fileno():
conn,addr=s.accept()
print 123