From 32a4a51964c9441023d45ecf8c2395875d4f9196 Mon Sep 17 00:00:00 2001 From: zzy <2450266535@qq.com> Date: Thu, 2 Nov 2023 23:21:03 +0800 Subject: [PATCH] dev send msg part --- test/client/client.c | 3 +++ test/project/client_proj/client_proj.c | 6 +++--- test/server/server.c | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/client/client.c b/test/client/client.c index 4c8f138..300fd87 100644 --- a/test/client/client.c +++ b/test/client/client.c @@ -47,6 +47,9 @@ int main(int argc, char** argv) if(getchar()); exit(-1); } + if (Buf[strlen(Buf) - 1] == '\n') { + Buf[strlen(Buf) - 1] = '\0'; + } res = send(cfd, Buf, strlen(Buf) + 1, 0); if (res == -1) { printf("send error %s", Buf); diff --git a/test/project/client_proj/client_proj.c b/test/project/client_proj/client_proj.c index 951c931..4f3670a 100644 --- a/test/project/client_proj/client_proj.c +++ b/test/project/client_proj/client_proj.c @@ -75,8 +75,8 @@ int main(int argc, char** argv) exit(-1); } szlocal_buf = strlen(local_buf); - if (local_buf[szlocal_buf] == '\n') { - local_buf[szlocal_buf] = '\0'; + if (local_buf[szlocal_buf-1] == '\n') { + local_buf[szlocal_buf-1] = '\0'; } else { szlocal_buf += 1; @@ -91,7 +91,7 @@ int main(int argc, char** argv) } log_head_info_ex(buf, BUFFER_SIZE, "send", g_mask); tprintf(&std_mutex, buf); - tprintf(&std_mutex, "[Buf]=%d,%s", szlocal_buf, local_buf); + tprintf(&std_mutex, "[send]=%d,\"%s\"\n", szlocal_buf, local_buf); } return 0; } \ No newline at end of file diff --git a/test/server/server.c b/test/server/server.c index 2e32509..0c877c9 100644 --- a/test/server/server.c +++ b/test/server/server.c @@ -88,7 +88,7 @@ int main() int res = make_server_sock(&sfd, _SOCKET_TEST_IP6, _SOCKET_TEST_PORT); if(res != 0) { printf("server start error\npress enter to continue"); - getchar(); + if(getchar()); return 0; } printf("server start...\n"); @@ -98,7 +98,7 @@ int main() printf("%s", Buf); if(strncasecmp(Buf, "exit", strlen("exit")) == 0) { printf("exit success\npress enter to continue"); - getchar(); + if(getchar()); exit(-1); } }