使用 setsockopt 设置 TCP_NODELAY
时间: 2023-12-27 19:24:05 浏览: 166
TcpNoDelay
```shell
const char chOpt=1;
int nErr=setsockopt( m_socket, IPPROTO_TCP, TCP_NODELAY, &chOpt, sizeof(char));
if(nErr==-1)
{
TRACE(_T("setsockopt() error\n"),WSAGetLastError());
return ;
}
```
```shell
case TCP_NODELAY:
if (val) {
tp->nonagle |= TCP_NAGLE_OFF|TCP_NAGLE_PUSH;
tcp_push_pending_frames(sk);
} else {
tp->nonagle &= ~TCP_NAGLE_OFF;
}
break;
```
阅读全文