On Mon, 30 Dec 2013 17:04:01 +0100, Sönke Ludwig wrote:
There is one issue that may prevent
TCPConnection
from being used for
this in a "sane" way. In the libevent driver it usesbufferevent
,
which has an internal prefetch buffer, so it would steal the incoming
data. But it should be possible to manually adopt a socket into the
libevent loop using a manually createdevent
without problems. That
would then just need to be encapsulated cleanly somehow. Maybe like this:interface SocketEventListener { enum Event { read = 1<<0, write = 1<<1, status = 1<<2, any = read|write|status } void wait(Event which = Event.any); } SocketEventListener createSocketEventListener(int socket);
Any idea for a better name or anything that would be missing?
Sounds good.
Timeout support would probably be good. Although I think this could be implemented outside of SocketEventListener it's probably easier to add support in SocketEventListener.