On Fri, Jul 5, 2013 at 2:06 AM, 陈邦义 <david.ban...@gmail.com> wrote:
> Bufferevent is a little different from raw Event. Every bufferevent created
> via function bufferevent_socket_new() has been assigned EV_READ| EV_PERSIST
> and EV_WRITE | EV_PERSIST flags.
>
> struct bufferevent * bufferevent_socket_new(......){
> ..............
> event_assign(&bufev->ev_read, bufev->ev_base,fd, EV_READ | EV_PERSIST,
> bufferevent_readcb, bufev);
> event_assign(&bufev->ev_write, bufev->ev_base,fd,EV_WRITE| EV_PERSIST,
> bufferevent_writecb, bufev);
> ............
> }
>
> so my write callback will be called by function 'bufferevent_writecb' under
> some conditions.  I need know this 'conditions'.

The write callback is invoked when the bufferevent's output buffer
becomes "drained enough".  Usually, that means that some data was
written, and the output buffer is now empty.  You can make it so that
the write callback happens even on nonempty buffers by setting a write
low-watermark.

This is documented in
http://www.wangafu.net/~nickm/libevent-book/Ref6_bufferevent.html

yrs,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majord...@freehaven.net with
unsubscribe libevent-users    in the body.

Reply via email to