selfboot / AnnotatedShadowSocks

Annotated shadowsocks(python version)
Other
3 stars 1 forks source link

fd in poll.register and other select functions. #17

Open selfboot opened 7 years ago

selfboot commented 7 years ago

poll.register(fd[, eventmask]) Register a file descriptor with the polling object. Future calls to the poll() method will then check whether the file descriptor has any pending I/O events. fd can be either an integer, or an object with a fileno() method that returns an integer. File objects implement fileno(), so they can also be used as the argument.

Note here: fd can be either an integer, or an object with a fileno() method that returns an integer.

So, in issue #15 #16, we use register and other functions just like:

# connection is a socket object and has fileno() function.
poller.register(connection, READ_ONLY)
epoller.register(connection, READ_ONLY)