From 11f2f2e329ef404d0e9c022cb2f9fbbb45bae285 Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: 周日, 27 4月 2025 17:33:31 +0800 Subject: [PATCH] 完成了SCPI命令语法分析器的完整规则 --- 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