On Wed, Mar 24, 2010 at 11:24 AM, Jarod Liu <liuyuan...@gmail.com> 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 majord...@freehaven.net with unsubscribe libevent-users in the body.