We have another question regarding this specification in the wiki:

support letting a connection "sleep" (no task allocated while waiting for the next request)

For this reason we were thinking of an event based approach that leverages the existing listenTCP function that currently states:

  • 'connection_callback' will be called for each client that connects to the server socket. Each new connection gets its own fiber. The stream parameter then allows to perform blocking I/O on the client socket.

If the callback can be called every time the socket is triggered (instead of just "new connection event") there is no need to keep a task allocated while waiting for new data.
This means exposing an API to add events to the event loop or adding every socket that gets accepted to the event loop and removing it accordingly.

Do you think this is the right approach? Did you have something else in mind?