Home >Backend Development >Python Tutorial >python实现Linux异步epoll代码

python实现Linux异步epoll代码

WBOY
WBOYOriginal
2016-06-06 11:14:481406browse

代码如下:


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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn