From c3c1259fabc2c4eda09721069aab17ba64290a1d Mon Sep 17 00:00:00 2001 From: Coldwings Date: Thu, 17 Apr 2025 16:55:11 +0800 Subject: [PATCH] Set TCP_NODELAY by default (#767) Fix TCPServer 40ms delay. Thanks @f0cii helps found and fix this problem. Co-authored-by: f0cii <2201441955@qq.com> --- net/kernel_socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/kernel_socket.cpp b/net/kernel_socket.cpp index 22f0c666..52b8a40d 100644 --- a/net/kernel_socket.cpp +++ b/net/kernel_socket.cpp @@ -315,7 +315,7 @@ class KernelSocketServer : public SocketServerBase { int bind(const EndPoint& ep) override { auto s = sockaddr_storage(ep); if (m_listen_fd < 0) { - m_listen_fd = socket(s.get_sockaddr()->sa_family, 0, m_nonblocking, false); + m_listen_fd = socket(s.get_sockaddr()->sa_family, 0, m_nonblocking, true); if (m_listen_fd < 0) return -1; } if (m_opts.setsockopt(m_listen_fd) != 0) { @@ -333,7 +333,7 @@ class KernelSocketServer : public SocketServerBase { LOG_ERRNO_RETURN(0, -1, VALUE(path)); } if (m_listen_fd < 0) { - m_listen_fd = socket(AF_UNIX, 0, true, false); + m_listen_fd = socket(AF_UNIX, 0, true, true); if (m_listen_fd < 0) LOG_ERRNO_RETURN(0, m_listen_fd, "failed to create UNIX domain socket at ", ALogString(path, count)); }