socket.write(data[, encoding][, callback])


在套接字上发送数据。 第二个参数指定字符串情况下的编码。 它默认为 UTF8 编码。

如果整个数据被成功刷新到内核缓冲区,则返回 true。 如果所有或部分数据在用户内存中排队,则返回 false。 当缓冲区再次空闲时,将触发 'drain'

可选的 callback 参数将在数据最终写完时执行(可能不会立即执行)。

有关更多信息,请参阅 Writablewrite() 方法。

Sends data on the socket. The second parameter specifies the encoding in the case of a string. It defaults to UTF8 encoding.

Returns true if the entire data was flushed successfully to the kernel buffer. Returns false if all or part of the data was queued in user memory. 'drain' will be emitted when the buffer is again free.

The optional callback parameter will be executed when the data is finally written out, which may not be immediately.

See Writable stream write() method for more information.