From 2a1fbbd629e4c1d7f636bbb7817bea1ba082981a Mon Sep 17 00:00:00 2001 From: folkert van heusden <mail@vanheusden.com> Date: 周五, 19 11月 2021 05:00:39 +0800 Subject: [PATCH] The problem of the fragmented *IDN? response can be mitigated somewhat by enabling nagle during the response to that command. --- examples/test-tcp/main.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c index 3853e01..f67df33 100644 --- a/examples/test-tcp/main.c +++ b/examples/test-tcp/main.c @@ -45,6 +45,7 @@ #include <errno.h> #include <arpa/inet.h> #include <unistd.h> +#include <netinet/tcp.h> #include "scpi/scpi.h" #include "../common/scpi-def.h" @@ -193,7 +194,7 @@ listenfd = createServer(5025); while (1) { - int clifd; + int clifd, flag = 0; struct sockaddr_in cliaddr; socklen_t clilen; @@ -202,6 +203,8 @@ if (clifd < 0) continue; + setsockopt(clifd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)); + printf("Connection established %s\r\n", inet_ntoa(cliaddr.sin_addr)); scpi_context.user_context = &clifd; -- Gitblit v1.9.1