socket.write(data[, encoding][, callback])
data
<string> | <Buffer> | <Uint8Array>encoding
<string> 仅当数据为string
时使用。 默认值:utf8
。callback
<Function>- 返回: <boolean>
在套接字上发送数据。 第二个参数指定字符串情况下的编码。 它默认为 UTF8 编码。
如果整个数据被成功刷新到内核缓冲区,则返回 true
。
如果所有或部分数据在用户内存中排队,则返回 false
。
当缓冲区再次空闲时,将触发 'drain'
。
可选的 callback
参数将在数据最终写完时执行(可能不会立即执行)。
有关更多信息,请参阅 Writable
流 write()
方法。
data
<string> | <Buffer> | <Uint8Array>encoding
<string> Only used when data isstring
. Default:utf8
.callback
<Function>- Returns: <boolean>
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.