socket.bufferSize
稳定性: 0 - 弃用:请改用
writable.writableLength。- 类型:<integer>
此属性显示已缓冲用于写入的字符数。缓冲区可能包含编码后长度尚未知的字符串。因此,该数字仅是缓冲区字节数的近似值。
【This property shows the number of characters buffered for writing. The buffer may contain strings whose length after encoding is not yet known. So this number is only an approximation of the number of bytes in the buffer.】
net.Socket 有一个特性,即 socket.write() 总是可以使用。这是为了帮助用户快速上手运行。然而,计算机并不总能跟上写入套接字的数据量。网络连接可能只是太慢。Node.js 会在内部将写入套接字的数据排队,并在可能的时候通过网络发送出去。
这种内部缓冲的结果是内存可能会增长。遇到 bufferSize 很大或增长的用户应尝试使用 socket.pause() 和 socket.resume() 来“节流”程序中的数据流。
【The consequence of this internal buffering is that memory may grow.
Users who experience large or growing bufferSize should attempt to
"throttle" the data flows in their program with
socket.pause() and socket.resume().】