From a3fdd3589c713678eafe20840a7334de6bed038b Mon Sep 17 00:00:00 2001
From: nancy.liao <huihui.liao@greentest.com.cn>
Date: 周五, 18 4月 2025 10:10:38 +0800
Subject: [PATCH] 修改

---
 examples/test-tcp/main.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c
index f67df33..436a4b9 100644
--- a/examples/test-tcp/main.c
+++ b/examples/test-tcp/main.c
@@ -51,17 +51,24 @@
 #include "../common/scpi-def.h"
 
 size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
-    (void) context;
-
     if (context->user_context != NULL) {
         int fd = *(int *) (context->user_context);
+
+        int state = 1;
+        setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
+
         return write(fd, data, len);
     }
     return 0;
 }
 
 scpi_result_t SCPI_Flush(scpi_t * context) {
-    (void) context;
+    if (context->user_context != NULL) {
+        int fd = *(int *) (context->user_context);
+
+        int state = 0;
+        setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
+    }
 
     return SCPI_RES_OK;
 }
@@ -172,6 +179,8 @@
 /*
  *
  */
+
+ //缃戠粶閫氫俊閮ㄥ垎鍙互涓嶄娇鐢ㄦ爣鍑咰鐨剆ocket閫氫俊锛屽彲浠ラ噰鐢–++鎴栬�匭t鐨勭綉缁滃簱杩涜浼犺緭
 int main(int argc, char** argv) {
     (void) argc;
     (void) argv;
@@ -194,7 +203,7 @@
     listenfd = createServer(5025);
 
     while (1) {
-        int clifd, flag = 0;
+        int clifd, flag = 1;
         struct sockaddr_in cliaddr;
         socklen_t clilen;
 

--
Gitblit v1.9.1