This is an example in http.cI wonder how can I get EVHTTP_CON_READING_ERROR?? Since when the connection is closed, I can only get an error code, and this code seems only telling your send or recv has finished or not.
evhttp_connection_read_on_write_error(struct evhttp_connection *evcon, struct evhttp_request *req) { struct evbuffer *buf; /** Second time, we can't read anything */ if (evcon->flags & EVHTTP_CON_READING_ERROR) { evcon->flags &= ~EVHTTP_CON_READING_ERROR; evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); return; } req->kind = EVHTTP_RESPONSE; buf = bufferevent_get_output(evcon->bufev); evbuffer_unfreeze(buf, 1); evbuffer_drain(buf, evbuffer_get_length(buf)); evbuffer_freeze(buf, 1); evhttp_start_read_(evcon); evcon->flags |= EVHTTP_CON_READING_ERROR; } On 03/20/2016 10:59 AM, Azat Khuzhin wrote:
On Sun, Mar 20, 2016 at 10:54:41AM -0400, Michael wrote:Hi all, I want to ask what should I do when the connection is closed while I am sending or recving data. For example the connection is closed by the server explicitly or because the server is down, when the client is still sending data or recving data. For libevent, if the connection is closed, event callback is invoked. But in this callback what should we do? Is there any common practice?That depends on your needs, you can take a look at http server for example: $ grep EOF libevent/http.c *********************************************************************** To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with unsubscribe libevent-users in the body.
*********************************************************************** To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with unsubscribe libevent-users in the body.