使用python實現(xiàn)Linux異步epoll的代碼
代碼如下:
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
【使用python實現(xiàn)Linux異步epoll的代碼】相關文章:
python輕松實現(xiàn)代碼編碼格式轉(zhuǎn)換03-18
Linux系統(tǒng)中strace命令的使用代碼01-30
Python怎么實現(xiàn)多行注釋10-29
php使用cookie實現(xiàn)記住用戶名和實現(xiàn)代碼08-12
如何使用Google-Code-Prettify 實現(xiàn)代碼高亮功能02-22
PHP滾動日志的代碼實現(xiàn)09-30