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

Re: [Libevent-users] how to flush output immediately?



All,
Thank you.  I'll try the callback way.

On Thu, Mar 25, 2010 at 12:54 AM, Nick Mathewson <nickm@xxxxxxxxxxxxx> wrote:
> On Wed, Mar 24, 2010 at 11:24 AM, Jarod Liu <liuyuanzhi@xxxxxxxxx> wrote:
>> I want to implement a server which listen on a port. When new
>> connection come, write out something, then close the connection.
>> I try use bufferevent_write put data to output buffer then
>> bufferevent_free, but I found the connection close without flush
>> output first.
>> How can I do that with the bufferevent interfaces?
>
> Don't free the bufferevent until it's done writing.  You can do this
> trivially in your case by adding a write callback to the bufferevent.
> Have the write callback check the size of the output buffer, and free
> the bufferevent when the output buffer becomes empty.
>
> yrs,
> --
> Nick
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users    in the body.
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.