基于libevent 实现的http服务C++(myhttp.cpp)
event_init(); //创建一个http server struct evhttp *httpd; httpd = evhttp_start(httpd_option_listen, httpd_option_port); evhttp_set_timeout(httpd, httpd_option_timeout); //指定generic callback evhttp_set_gencb(httpd, httpd_handler, NULL); //也可以为特定的URI指定callback //evhttp_set_cb(httpd, "/", specific_handler, NULL); //循环处理events event_dispatch(); evhttp_free(httpd);
用户评论