[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Re:
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] Re:
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Mon, 8 Mar 2010 23:14:27 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Mon, 08 Mar 2010 23:14:34 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=zrIOll8GpfE+rrLXc/Msf4aFcQ1uhl8LY1AKRmvXCFA=; b=H1qYkJMIK7RSWl8pGqtMjzh3ofrR2TJsP7jzqXQT2oLkYA6ZamCYBHq6uhbcZToJLN 9DD8d9rdPJNpRJ9Gv2UU3IW5JhuGJOkugsXHFBVxiHPhLF8iuKW3C39LBv+uIkSo8tvp Z99oaAzDfrizqXKVC5ywN38h08NTK5arDNceI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=TEKNCt759f8ZNENX5Gw0Bhw9nuEojH9zbQf04zqKi5R8CLrtCEUmGf4qdgRpisbyUN jOKNQNJ35F9lm1EaLEGGFVKqIolSF82kiBPy04IfMSjT6DP+SFFeqbbjNSO6w/UoD6uh qjVlAkc/0Qi+nFuAUI+vCfS8YPzfaVA/PRkDs=
- In-reply-to: <74654.68492.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- References: <74654.68492.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Sat, Feb 27, 2010 at 9:32 AM, ash ar <ashar51985@xxxxxxxxx> wrote:
> Hi,
>
> I have tried to embed libevent as a static library with my C++ application
> and would like to get http requests in my c++ application. Seems it works
> fine normally.
>
> I have use the following code..
>
> ______________________________________________
>
> void WebServer::ProcessHandler(struct evhttp_request *req, void *arg)
> {
>
> struct evbuffer *buf;
> buf = evbuffer_new();
>
> if (buf == NULL)
> cout << "failed to create response buffer";
>
> char* uriInput = NULL;
> if (req->type == EVHTTP_REQ_GET)
> {
> uriInput = (char*)evhttp_request_uri(req);
> }
> else if (req->type == EVHTTP_REQ_POST)
> {
> struct evbuffer *input_headers = evbuffer_new();
> input_headers = req->input_buffer;
> uriInput = (char*)input_headers->buffer;
> }
>
> evbuffer_add_printf(buf, "Requested: %s\n", evhttp_request_uri(req));
> evhttp_send_reply(req, HTTP_OK, "OK", buf);
>
> evhttp_connection_free(req->evcon);
> free(uriInput);
> evbuffer_free(buf);
>
> return;
> };
>
> void webserver::ThreadProcess()
> {
> struct evhttp *httpd;
>
> event_init();
> httpd = evhttp_start("0.0.0.0", 8080);
>
> evhttp_set_cb(httpd, "/", &WebServer::ProcessHandler, NULL);
>
> event_dispatch();
>
> evhttp_free(httpd);
> }
>
> __________________________________________________
>
> But seems, the above code does not work as a threaded function. ie, call the
> same functions from different thread , when a first call is in progress I
> want to try a second call synchronously.
I'm not sure I get the question completely. You want to call the some
functions (what functions?) from two threads once? Or you want the
callback to execute in a different thread from your main code? Or you
want two callbacks to execute at once?
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.