Skip to content

Instantly share code, notes, and snippets.

@asim
Created March 30, 2011 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asim/894267 to your computer and use it in GitHub Desktop.
Save asim/894267 to your computer and use it in GitHub Desktop.
ignore this
#include <stdio.h>
#include <event.h>
#include <evhttp.h>
#include <stdlib.h>
struct server {
struct event_base *base;
struct evhttp *http;
};
void on_request(struct evhttp_request *r, void *ctx) {
const char *uri = evhttp_request_uri(r);
struct server *thing = ctx;
int ret;
evhttp_send_reply(r, 200, "Hello World", NULL);
}
int main(int argc, char *argv[]) {
struct server *thing = calloc(1, sizeof(struct server));
char host[] = "127.0.0.1";
int port = 8009;
thing->base = event_base_new();
thing->http = evhttp_new(thing->base);
evhttp_bind_socket(thing->http, host, port);
evhttp_set_gencb(thing->http, on_request, thing);
event_base_dispatch(thing->base);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment