From 2612d4811f72395354fd895daffd494edc46fbfe Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 04 八月 2020 16:27:51 +0800 Subject: [PATCH] fix sendandrecv --- test_socket/dgram_mod_req_rep.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/test_socket/dgram_mod_req_rep.c b/test_socket/dgram_mod_req_rep.c index 4ec451f..746ae19 100644 --- a/test_socket/dgram_mod_req_rep.c +++ b/test_socket/dgram_mod_req_rep.c @@ -72,6 +72,20 @@ dgram_mod_close_socket(socket); } +void client2(int port) { + void *socket = dgram_mod_open_socket(); + int size; + void *recvbuf; + char sendbuf[512]; + while (true) { + sprintf(sendbuf, "hello\n" ); + dgram_mod_sendandrecv(socket, sendbuf, strlen(sendbuf) + 1, port, &recvbuf, &size); + printf("reply: %s\n", (char *)recvbuf); + free(recvbuf); + } + dgram_mod_close_socket(socket); +} + void *runclient(void *arg) { @@ -152,7 +166,7 @@ } if (strcmp("client", argv[1]) == 0) - client(port); + client2(port); return 0; -- Gitblit v1.8.0