Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

C++11 port for Node.js

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc
Octocat-spinner-32 native
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.md
Octocat-spinner-32 file_test.cpp
Octocat-spinner-32 webclient.cpp
Octocat-spinner-32 webserver.cpp
README.md

node.native

node.native is a C++11 (aka C++0x) port for node.js.

Please note that node.native project is under heavy development: currently experimental.

Sample code

Simplest web-server example using node.native.

#include <iostream>
#include <native/native.h>
using namespace native::http;

int main() {
    http server;
    if(!server.listen("0.0.0.0", 8080, [](request& req, response& res) {
        res.set_status(200);
        res.set_header("Content-Type", "text/plain");
        res.end("C++ FTW\n");
    })) return 1; // Failed to run server.

    std::cout << "Server running at http://0.0.0.0:8080/" << std::endl;
    return native::run();
}

Getting started

node.native consists of header files(*.h) only, but requires libuv and http-parser lib to use.

To compile included sample application(webserver.cpp):

export LIBUV_PATH=/path/to/libuv_dir
export HTTP_PARSER_PATH=/path/to/http-parser_dir

then,

make

I tested the code on Ubuntu 11.10 and GCC 4.6.1.

Other Resources

You can also access this page via http://www.nodenative.com.

Something went wrong with that request. Please try again.