I would like to use bufferevent_filter atop an unconnected UDP socket. Maybe I’m wrong but it doesn’t seem to be trivial to do. Feel free to explain me the correct way if that’s the case ;-).
I’ve started some work to try decoupling evbuffer callback from the rest of evbuffer’s code, and you can see the idea there : http://github.com/tiennou/libevent/tree/evbuffer_fd_cbs
but I wanted to have developer advice on this before continuing :
- My primary goal is being able to get/set the sockaddr an evbuffer will be sent to, represented by struct evsocket_info in evsocket.c. This could be extended to give access to OOB data, though I’m not interested in this one.
- libevent would provide callbacks for existing methods, see methods.txt, I’ve described them all there, and I extracted the current implementation from evbuffer_read/write to functions in evsocket.c.
- The client (library user) would then be able to provide its own read/write callbacks if he wanted to.
- Right now evbuffer is unchanged (except for the read/write decoupling), but it would need a new function for setting another set of callbacks, and another one to get/set the evsocket_info for an evbuffer.
- I’m not sure about how to handle the multiple callbacks. I thought about doing something akin to event_config (which explains the flag mess), but I don’t like that. Another way would be automatic select of the best read/write pair, if I manage to find information on how to detect the underlying fd type (file, sendfile, connected socket, unconnected socket, iovec support). Selection would be made at first read/write attempt, then cached in the evbuffer.
- I’m not sure about binary compat, but since this is alpha, I’m not sure it matters.
What are your thoughts on this ?
This is fairly complicated and ambitious! Congratulations!
Right now, evbuffer and bufferevent aren't really designed to handle UDP except by accident. It would be very good to fix that, though I'm not sure if we can do so effectively by the time 2.0.x-stable comes out.
Still, we will *definitely* want to have UDP support as soon as we can get it.
I'm going to move this item into "patches", since it's closer to an actual applicable patch than a feature request.