[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] UDP Support



On Wed, Dec 12, 2012 at 1:56 PM, Scott Dorr <j.scott.dorr@xxxxxxxxx> wrote:
> UDP works fine in libevent. I have several UDP based applications that run solely over UDP.
>
> You might have to run edge triggered to support UDP. I know I had to move to edge triggered, though I can't recall if that was for UDP, or for the OS I was using, or a combination.

I'm pretty sure John is asking about UDP support under bufferevents.
That's nontrivial.

The last time I looked, it appeared that the  socket-backed
bufferevent code was almost exactly right for a UDP transition, but
that the underlying evbuffer objects didn't have a lot of sensible
overlap in their API.  Internally, evbuffers are optimized for
stream-oriented data, and it's not easy to come up with an elegant way
to make them handle packet-oriented data instead, especially if you
want the packet-oriented data to come with optional addresses (to
support unconnected UDP sockets with sendfrom/recvto), and you want to
avoid excessive copy operations, and you don't want to need one malloc
per packet.

I think that one sensible idea here might involve finding a
backward-compatible way to split evbuffer into a generic supertype,
with two (packet-oriented, stream-oriented) subtypes.  But that'll
still be tricky.

(FWIW, you don't need edge-triggered IO enabled to do UDP support with
Libevent -- evdns does just fine without edge-triggered events.)

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.