wolkykim / libasyncd

Libasyncd is an embeddable event-based asynchronous Message/HTTP server framework for C/C++.

Home Page:http://wolkykim.github.io/libasyncd/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Are more than one protocol without threads possible?

berndpetrovitsch opened this issue · comments

Is it (somewhat easily) possible to have different callbacks registered on different ports (e.g.because the implement different protocols) without threads?
And for this, one needs to (also) hook some buffer transfer logic as the daemon mustn't block.

So the basic idea is:

  • register various callbacks to various (different) ports
  • the callbacks are called if data is available. the callback functions buffer the data and handle it, if enough data is here (e.a. a complete request).
  • the response is constructed (non-blocking) and stored in some buffer (and is gradually transmitted).

Using threads just adds the complexity for internal explicit synchronization ....

As you probably know already, libasyncd listens on single port per server. So for now, it probably needs multiple servers to listen on multiple ports. So my answer to the question is no.

I guess you'd like to run different type of requests on different ports but handles them all from single thread. If the type of requests on various ports can be determined from the input data rather than tcp port number, I guess you could consider port forwarding technique.