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

[Libevent-users] Re: Closing bufferevents sockets from the server side



Ok I am feeling that 
struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer,
    evbuffer_cb_func cb, void *cbarg);

might be the solution to my problems...? Adding a calbaack to see how much data is drained from the buffer??

On Tue, Nov 23, 2010 at 9:00 PM, Sid <itissid@xxxxxxxxx> wrote:
Sorry that got posted by mistake in the wrong thread... here it is again...

Hi,
I am using libevent 2.03 alpha 1 to create an app. The app structure is as follows:

A C++ app wraps lib event to listen on a domain socket. I use buffered events. As you can see in the post, the post above is a simple server that loops over a set of docs and creates many connections to this server.  

I am new to this so please spare my flaky concepts, I want to clarify my doubt
1) I am using a buffered event that uses sockets as its underlying transport means. Everytime a connection is received a connection handler forms an eventbuffer, attaches a write handler and a eventcb handler.

2) I recieve some data from the client, I read a line process it and write it onto the output buffer of the bufferevent object.

The problem: Now I want to just flush this buffer and close the underlying transport(socket) after data has been flushed. I will call the evbuffer_add only once for each line recieved and after that no more data will be written to that specific o/p buffer. 
So at this point i know exactly how much data to write. I need to reliably close this connection after all these bytes are out. How to achieve this?

Sid