소스 검색

tcp_nodelay

ithewei 3 년 전
부모
커밋
fdf0e4a695
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      examples/tinyhttpd.c

+ 2 - 0
examples/tinyhttpd.c

@@ -393,6 +393,7 @@ static hloop_t* get_next_loop() {
 }
 
 static void on_accept(hio_t* io) {
+    tcp_nodelay(hio_fd(io), 1);
     hio_detach(io);
 
     hloop_t* worker_loop = get_next_loop();
@@ -416,6 +417,7 @@ static HTHREAD_ROUTINE(accept_thread) {
     if (listenio == NULL) {
         exit(1);
     }
+    tcp_nodelay(hio_fd(listenio), 1);
     printf("tinyhttpd listening on %s:%d, listenfd=%d, thread_num=%d\n",
             host, port, hio_fd(listenio), thread_num);
     // NOTE: add timer to update date every 1s