On Wed, Nov 20, 2013 at 12:38 PM, Mickey Kawick <mic...@playdekgames.com> wrote: > Super cool Matt. In this example, adding "evthread_use_windows_threads" > worked perfectly. I got the exact echo that I was expecting. > > What is the best way to write to that buffer? I am using this: > > struct evbuffer* outputBuffer = bufferevent_get_output( bev ); > evbuffer_add( outputBuffer, buffer, length ); > > int result = evbuffer_write( outputBuffer, socketId ); > evbuffer_drain( outputBuffer, length ); > cout << "Write result = " << result << endl; > > Is there a better way?
You shouldn't need to call evbuffer_write() manually on a bufferevent's output buffer, and you shouldn't call evbuffer_drain() after evbuffer_write() since evbuffer_write() removes the data itself after writing it. Just use evbuffer_add to add the information to the output buffer, and the write event on the buffer will make it get written to the network. best wishes, -- Nick *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.