yhirose 2 周之前
父节点
当前提交
9ced2f614d
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      httplib.h

+ 4 - 0
httplib.h

@@ -11319,6 +11319,10 @@ inline bool Server::listen_internal() {
       detail::set_socket_opt_time(sock, SOL_SOCKET, SO_SNDTIMEO,
                                   write_timeout_sec_, write_timeout_usec_);
 
+      if (tcp_nodelay_) {
+        detail::set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1);
+      }
+
       if (!task_queue->enqueue(
               [this, sock]() { process_and_close_socket(sock); })) {
         output_error_log(Error::ResourceExhaustion, nullptr);