开发者

Could Node.js run client side in Chrome with its native client (to be released soon)

Google Chrome's native client is soon to be released. h开发者_JAVA百科ttp://blog.chromium.org/2011/02/native-client-getting-ready-for-takeoff.html Would this allow node.js to be run within the browser enabling distributed applications to communicate with each other without having to go through the server?


Nowadays there are several solutions that allow you to run some Node modules in chrome. Have a look on these links:

  • node-webkit is an app runtime based on Chromium and node.js.

  • Node-chromify, Node.js in Chrome.

  • Screen cast from google about NodeJS in Chrome packaged apps.


As of today, Node.js will not run in NaCl, however it may be possible eventually. Node uses the V8 JavaScript engine to execute code. Currently there is no reliable port of the V8 engine that will run within NaCl.

From a comment by Brad Chen on Jan 28, 2014, in the thread "Has anyone tried porting Blink and V8 to Native Client?":

V8 has been ported to Native Client, although the port used an unsavory trick of having V8 generate ARM instructions and then use a portable ARM interpreter to avoid the need to port V8 code generators to NaCl. You should be able to observe this by checking out V8 source and following the standard build/test instructions using targets nacl_ia32 or nacl_x64.

https://groups.google.com/d/msg/native-client-discuss/Xw5yCe3Ubwc/fgm6M092DXwJ

Considering that V8 has already been able to run under NaCl, albeit with an unreliable hack, it's reasonable to assume that Node might eventually be able to run in NaCl. I realize your question is now three years old but figured I'd provide an updated answer since running native code (even OpenGL code) in the browser is now a reality.


node.js is not pure Javascript code. There are parts of it written in C++ so this is unlikely.

There are a couple of possibilities for distributed communication. One is to use the Websockets api in the browser to communicate with other browsers. The other one is to run node.js as a separate server process on the same machine as the browser.

This second is a better choice for building a distributed application because it reduces dependence on the browser. Version 0.5.0pre of node.js now builds OK on Cygwin and it is possible to bundle up the essential components of Cygwin as a standalone binary to distribute to Windows clients. Older versions of node.js used to be distributed this way.


You can't run Node.js in a browser.

However, if you want to do P2P connection, it's possible if the browser has the latest version of Flash (Flash 10) installed. In the latest version, they introduced RTMFP which let's you do P2P connection without passing through a server. If you want to use it in Javascript, you can make a bridge or you can take a look at a project I started recently that does exactly that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜