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

Re: [Libevent-users] evbuffer - how to read without draining data?



On Wed, Mar 31, 2010 at 7:10 AM, Sebastian Sjöberg
<Sebastian.Sjoberg@xxxxxxxx> wrote:
> On Mar 31, 2010, at 10:02 AM, Jarod Liu wrote:
>
>> Hi,
>> I writing a eventbuffer socket app. My app packet have a length
>> header, I want to read data only when input buffer length > packet
>> length(I need to read the length header first). But it seems like I
>> can't read from evbuffer without draining data. Is there a way to do
>> that?
>
> Hi,
>
> You can do evbuffer_pullup() with the size of your length header and reading the length header from the returned pointer.

You can also use evbuffer_peek() (in Libevent 2.0) if you want to look
at the header without moving any data around in the evbuffer
internally.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.