javascript - MMO WebSocket Server: Node.js or C++? -


i have been thinking of making real-time game websockets web. know how use node.js, , tempting make on there. everywhere look, c++ seems popular server language because of speed.

should give making in node.js go, , worry c++ later, or should learn c++ , make in there scratch?

if decide go c++ route (and offer best performance of language), there's great open source websocket library heavy lifting you. header-only , uses boost. comes example code , documentation: http://vinniefalco.github.io/

here's complete program sends message echo server:

#include <beast/websocket.hpp> #include <beast/buffers_debug.hpp> #include <boost/asio.hpp> #include <iostream> #include <string>  int main() {     // normal boost::asio setup     std::string const host = "echo.websocket.org";     boost::asio::io_service ios;     boost::asio::ip::tcp::resolver r(ios);     boost::asio::ip::tcp::socket sock(ios);     boost::asio::connect(sock,         r.resolve(boost::asio::ip::tcp::resolver::query{host, "80"}));      using namespace beast::websocket;      // websocket connect , send message using beast     stream<boost::asio::ip::tcp::socket&> ws(sock);     ws.handshake(host, "/");     ws.write(boost::asio::buffer("hello, world!"));      // receive websocket message, print , close using beast     beast::streambuf sb;     opcode op;     ws.read(op, sb);     ws.close(close_code::normal);     std::cout <<         beast::debug::buffers_to_string(sb.data()) << "\n"; } 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -