#730 net.server: Generic API for watching a file descriptor

Reporter Zash
Owner Nobody
Created
Updated
Stars ★ (1)  
Tags
  • Type-Enhancement
  • Priority-Medium
  • Status-Accepted
  1. Zash on

    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.

  2. Zash on

    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.

  3. Zash on

    Changes
    • tags Status-Accepted

New comment