HTTP
libtnet提供了简单的http支持,使用也很简单。
一个简单的http server:
void onHandler(const HttpConnectionPtr_t& conn, const HttpRequest& request)
{
HttpResponse resp;
resp.statusCode = 200;
resp.setContentType("text/html");
resp.body.append("Hello World");
conn->send(resp);
}
TcpServer s;
HttpServer httpd(&s);
httpd.setHttpCallback("/test", std::bind(&onHandler, _1, _2));
httpd.listen(Address(80));
s.start(4);
我们对http server的"/test"注册了一个handler
最后
以上就是现实大炮最近收集整理的关于高性能C++网络库libtnet实现:httpHTTPHTTP ParserWebsocket的全部内容,更多相关高性能C++网络库libtnet实现:httpHTTPHTTP内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复