[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Libevent2 - Support for UDP in bufferevent
On Wed, Dec 1, 2010 at 8:22 AM, Thai Duong <thaidn@xxxxxxxxx> wrote:
> Hi everybody,
>
> I'm new to this list, so please forgive me if this has been discussed.
> I read the libevent2 book, and it said that bufferevent currently
> supports only TCP socket. I take a look at the code, and see that,
> however, it seems that bufferevent can work with UDP too.
The evbuffer backend that bufferevents uses to store incoming and
outgoing data currently assumes that it's handling stream data rather
than datagrams, and as such does not preserve packet boundaries when
reading and writing.
There are probably other issues as well, but that one's enough of a
showstopper to make bufferevents+UDP unworkable in the current code
base.
> So my
> question is why the book said that UDP is not supported?
Because it's the truth.
> And if that
> is really the case, what should I do to modify bufferevent so that it
> supports UDP?
It will probably take a fair amount of programming. You'd want to
start by thinking about the appropriate abstractions at the evbuffer
level, and then considering which abstractions are appropriate for
making evbuffers work on packets rather than streams without making
either implementation inefficient or making either API ugly or hard to
use. At the same time, you'd want to have a look through the
bufferevent code and see what stream-only assumptions (if any) it
makes, and what would need to be done to fix those.
Etienne Samson was working on a design for this a while back, and I'd
like to revisit it for Libevent 2.1. You can have a look at the state
of his work here:
https://sourceforge.net/tracker/?func=detail&aid=2928202&group_id=50884&atid=461324
. It makes some choices that I didn't agree with at the time, though
to be honest I haven't looked at it recently and can't currently
remember which they were.
This is also probably a good time to apologize to Etienne for being so
slow here; the Libevent 2.0 release cycle has been entirely too long.
Once 2.0.x-stable is out, it's probably a good idea to consider ways
to make sure that 2.1 does not spend so long in alpha as 2.0.x did.
yrs,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.