socket.bufferSize
此属性显示为写入而缓冲的字符数。 缓冲区可能包含编码后长度未知的字符串。 所以这个数字只是缓冲区中字节数的近似值。
net.Socket
具有 socket.write()
始终有效的特性。
这是为了帮助用户快速启动和运行。
计算机无法始终跟上写入套接字的数据量。
网络连接可能太慢了。
Node.js 将在内部对写入套接字的数据进行排队,并在可能的情况下通过网络将其发送出去。
这种内部缓冲的结果是内存可能会增长。
经历过大型或不断增长的 bufferSize
的用户应该尝试使用 socket.pause()
和 socket.resume()
来"节流"他们程序中的数据流。
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
has the property that socket.write()
always works. This is to
help users get up and running quickly. The computer cannot always keep up
with the amount of data that is written to a socket. The network connection
simply might be too slow. Node.js will internally queue up the data written to a
socket and send it out over the wire when it is possible.
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()
.