socket.setNoDelay([noDelay])
noDelay
<boolean> 默认值:true
- 返回: <net.Socket> 套接字自身
启用/禁用 Nagle 算法的使用。
创建 TCP 连接时,它将启用 Nagle 算法。
Nagle 的算法在数据通过网络发送之前延迟数据。 它试图以延迟为代价来优化吞吐量。
为 noDelay
传入 true
或不传入参数将禁用套接字的 Nagle 算法。
为 noDelay
传入 false
将启用 Nagle 的算法。
noDelay
<boolean> Default:true
- Returns: <net.Socket> The socket itself.
Enable/disable the use of Nagle's algorithm.
When a TCP connection is created, it will have Nagle's algorithm enabled.
Nagle's algorithm delays data before it is sent via the network. It attempts to optimize throughput at the expense of latency.
Passing true
for noDelay
or not passing an argument will disable Nagle's
algorithm for the socket. Passing false
for noDelay
will enable Nagle's
algorithm.