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

[Libevent-users] Re: how to prevent server close the connection?



/**
 * Binds an HTTP server on the specified address and port.
 *
 * Can be called multiple times to bind the same http server
 * to multiple different ports.
 *
 * @param http a pointer to an evhttp object
 * @param address a string containing the IP address to listen(2) on
 * @param port the port number to listen on
 * @return a newly allocated evhttp struct
 * @see evhttp_free()
 */
int evhttp_bind_socket(struct evhttp *http, const char *address, u_short port);

confused by return type in evhttp.h version 1.4.13 stable



2011/6/27 æç|åäæ <calidion@xxxxxxxxx>:
> here is the handler code, is there any thing wrong?
>
>     void HTTPServer::CometHandler(struct evhttp_request *req, void *arg) {
>   71       int i, j;
> .> 72       cout << "inside coment handler" << endl;
>   73       struct evbuffer *buf;
>   74
>   75       req->minor = 0;
>   76       evhttp_add_header(req->output_headers, "Content-Type",
> "text/plain");
>   77
>   78       evhttp_send_reply_start(req, HTTP_OK, "OK");
>   79       evhttp_connection_set_closecb(req->evcon, on_close, NULL);
>   80
>   81       buf = evbuffer_new();
>   82       evbuffer_add_printf(buf, "hello comet");
>   83       evhttp_send_reply_chunk(req, buf);
>   84
>   85     }
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.