#730 net.server: Generic API for watching a file descriptor
Description of feature:
Sometimes we want to poll a FD that is not a TCP connection that should be entirely handled by net.server. Currently there are a few modules that do this using various hacks, including net.adns (for UDP), mod_auth_external (for a child process handle) and the libunbound integration someone wrote. server_event.addevent() is relatively nice but tied to libevent/luaevent.
So I propose a simple API like this be added to all net.server variants:
server.watchfd( fd, readcallback, writecallback ) → handle
where 'fd' would be either an integer or an object with a :getfd() method.
The handle should at the very least have a :close() method.
A way for the callbacks to change if it wants to wait for the FD to be readable, writable or both would also be good.
Eg by returning some special status code or a method on the handle.