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

Reporter Zash
Owner Zash
Stars ★ (1)
  • Priority-Medium
  • Type-Enhancement
  • Milestone-0.11
  • Status-Fixed
  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

    • tags Status-Accepted
  4. Zash on

    This was apparently done in https://hg.prosody.im/trunk/rev/53178b6ba589

    • owner Zash
    • tags Milestone-0.11 Status-Fixed

New comment

Not published. Used for spam prevention and optional update notifications.