Node.js进程间通信?

Node.js进程间通信?,node.js,ipc,Node.js,Ipc,Node.js是否提供了任何标准的IPC方式,就像在许多其他语言中一样?我是Node.js新手,我找到的所有信息都是关于使用child_process.fork()或sockets的。您尝试过Node包吗 根据他们的文档,可能的示例是服务器: var ipc=require('node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; ipc.serve( function(){ ipc.server.

Node.js是否提供了任何标准的IPC方式,就像在许多其他语言中一样?我是Node.js新手,我找到的所有信息都是关于使用child_process.fork()或sockets的。

您尝试过Node包吗

根据他们的文档,可能的示例是服务器:

var ipc=require('node-ipc');

ipc.config.id   = 'world';
ipc.config.retry= 1500;

ipc.serve(
    function(){
        ipc.server.on(
            'message',
            function(data,socket){
                ipc.log('got a message : '.debug, data);
                ipc.server.emit(
                    socket,
                    'message',  //this can be anything you want so long as
                                //your client knows.
                    data+' world!'
                );
            }
        );
    }
);

ipc.server.start();
客户可能的解决方案:

 var ipc=require('node-ipc');

ipc.config.id   = 'hello';
ipc.config.retry= 1500;

ipc.connectTo(
    'world',
    function(){
        ipc.of.world.on(
            'connect',
            function(){
                ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
                ipc.of.world.emit(
                    'message',  //any event or message type your server listens for
                    'hello'
                )
            }
        );
        ipc.of.world.on(
            'disconnect',
            function(){
                ipc.log('disconnected from world'.notice);
            }
        );
        ipc.of.world.on(
            'message',  //any event or message type your server listens for
            function(data){
                ipc.log('got a message from world : '.debug, data);
            }
        );
    }
);

你是说本地人?或者节点进程之间的通信?在我的例子中,我们需要进程之间的通信,但本地IPC将是理想的。