process.send(message[, sendHandle[, options]][, callback])


  • message <Object>
  • sendHandle <net.Server> | <net.Socket>
  • options <Object> 用于参数化某些类型句柄的发送。options 支持以下属性:
    • keepOpen <boolean> 当传入 net.Socket 实例时可以使用的值。 当为 true 时,套接字在发送过程中保持打开状态。 默认值: false
  • callback <Function>
  • 返回: <boolean>

如果使用 IPC 通道衍生 Node.js,则可以使用 process.send() 方法向父进程发送消息。 消息将作为父对象 ChildProcess 对象上的 'message' 事件接收。

如果 Node.js 没有使用 IPC 通道衍生,则 process.send 将是 undefined

消息经过序列化和解析。 结果消息可能与最初发送的消息不同。

  • message <Object>
  • sendHandle <net.Server> | <net.Socket>
  • options <Object> used to parameterize the sending of certain types of handles.options supports the following properties:
    • keepOpen <boolean> A value that can be used when passing instances of net.Socket. When true, the socket is kept open in the sending process. Default: false.
  • callback <Function>
  • Returns: <boolean>

If Node.js is spawned with an IPC channel, the process.send() method can be used to send messages to the parent process. Messages will be received as a 'message' event on the parent's ChildProcess object.

If Node.js was not spawned with an IPC channel, process.send will be undefined.

The message goes through serialization and parsing. The resulting message might not be the same as what is originally sent.