On Tue, Jun 12, 2012 at 10:25 AM, Salim Moahmed <salem.amer.moha...@gmail.com> wrote: > How can I use the bufferevents to force the read buffer to send its data > immediately to a write-buffer that will forward its data as it comes to > another socket?
If I understand right, then you want to set up two bufferevents on two sockets, and have all data that is read on one socket written to the other. If that's what you want, the easiest way to do that is to set a read handler on the first bufferevent, and in that read handler use evbuffer_add_buffer() to move all data from the first bufferevent's input evbuffer into the second's output buffer. If this is going to get used in production, you will need to do something to solve the problem where the first socket can read faster than the second can write. The easiest way to do that is by using the "watermarks" feature so that the reading buffer does not grow above a certain size, and changing the read callback so that it does not move data to the output buffer if the output buffer is too full. If you do that, you will need some way (like a write callback on the output bufferevent) to notice that the output buffer is no longer too full, and then to drain data from the input buffer. hth, -- Nick *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.