Poll handles are used to watch file descriptors for readability, writability and disconnection similar to the purpose of poll(2)
.
The purpose of poll handles is to enable integrating external libraries that rely on the event loop to signal it about the socket status changes, like c-ares or libssh2. Using uv_poll_t for any other purpose is not recommended; :cuv_tcp_t
, :cuv_udp_t
, etc. provide an implementation that is faster and more scalable than what can be achieved with :cuv_poll_t
, especially on Windows.
It is possible that poll handles occasionally signal that a file descriptor is readable or writable even when it isn't. The user should therefore always be prepared to handle EAGAIN or equivalent when it attempts to read from or write to the fd.
It is not okay to have multiple active poll handles for the same socket, this can cause libuv to busyloop or otherwise malfunction.
The user should not close a file descriptor while it is being polled by an active poll handle. This can cause the handle to report an error, but it might also start polling another socket. However the fd can be safely closed immediately after a call to :cuv_poll_stop
or :cuv_close
.
Note
On windows only sockets can be polled with poll handles. On Unix any file descriptor that would be accepted by poll(2)
can be used.
Note
On AIX, watching for disconnection is not supported.
N/A
The :cuv_handle_t
members also apply.
The :cuv_handle_t
API functions also apply.