libnode C++版本的Node.js 项目简介
libnode 是 C++ 语言版的 Node.js,和 Node.js 一样,libnode 提供了非堵塞的 I/O,可让你用 C++ 开发可伸缩的 Web 应用,实现了基于 shared_ptr 或 bdw-gc 自动的内存管理。libnode 很适合在嵌入式设备上使用,因为其系统资源消耗非常的低。示例代码:http::Server::Ptr srv = http::Server::create(
JsClosure::create([] (JsArray::Ptr args) -> Value {
http::ServerResponse::Ptr res =
args->getPtr<http::ServerResponse>(1);
res->setHeader(
http::HEADER_CONTENT_TYPE,
String::create("text/plain"));
res->end(String::create("Hello World\n"));
return Status::OK;
}));
srv->listen(1337, String::create("127.0.0.1"));
node::run();
JsClosure::create([] (JsArray::Ptr args) -> Value {
http::ServerResponse::Ptr res =
args->getPtr<http::ServerResponse>(1);
res->setHeader(
http::HEADER_CONTENT_TYPE,
String::create("text/plain"));
res->end(String::create("Hello World\n"));
return Status::OK;
}));
srv->listen(1337, String::create("127.0.0.1"));
node::run();