| Index: net/socket/tcp_socket_posix.cc
|
| diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc
|
| index 68229ff68435ba7e077f80122bb95dbf9e0264e2..0546e6075a57e7663640ac93993b8fa71f1cd3e4 100644
|
| --- a/net/socket/tcp_socket_posix.cc
|
| +++ b/net/socket/tcp_socket_posix.cc
|
| @@ -43,6 +43,16 @@
|
| bool g_tcp_fastopen_user_enabled = false;
|
| // True if TCP FastOpen connect-with-write has failed at least once.
|
| bool g_tcp_fastopen_has_failed = false;
|
| +
|
| +// SetTCPNoDelay turns on/off buffering in the kernel. By default, TCP sockets
|
| +// will wait up to 200ms for more data to complete a packet before transmitting.
|
| +// After calling this function, the kernel will not wait. See TCP_NODELAY in
|
| +// `man 7 tcp`.
|
| +bool SetTCPNoDelay(int fd, bool no_delay) {
|
| + int on = no_delay ? 1 : 0;
|
| + int error = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
|
| + return error == 0;
|
| +}
|
|
|
| // SetTCPKeepAlive sets SO_KEEPALIVE.
|
| bool SetTCPKeepAlive(int fd, bool enable, int delay) {
|
|
|