From e994d555ba64d68d874099ed7c1b9e22c0b592b0 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 01 十二月 2020 15:45:11 +0800 Subject: [PATCH] update --- test_socket/dgram_mod_req_rep.c | 33 +++++++++++++++++++++++++-------- 1 files changed, 25 insertions(+), 8 deletions(-) diff --git a/test_socket/dgram_mod_req_rep.c b/test_socket/dgram_mod_req_rep.c index 4ec451f..54cbe4b 100644 --- a/test_socket/dgram_mod_req_rep.c +++ b/test_socket/dgram_mod_req_rep.c @@ -1,5 +1,5 @@ #include "dgram_mod_socket.h" -#include "shm_mm.h" +#include "shm_mm_wraper.h" #include "usg_common.h" #include "lock_free_queue.h" @@ -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) { @@ -136,7 +150,7 @@ int main(int argc, char *argv[]) { - shm_init(512); + shm_mm_wrapper_init(512); int port; if (argc < 3) { fprintf(stderr, "Usage: reqrep %s|%s <PORT> ...\n", "server", "client"); @@ -146,13 +160,16 @@ port = atoi(argv[2]); if (strcmp("server", argv[1]) == 0) { - int temp = shm_alloc_key(); - printf("tmp=%d\n", temp); - server(temp); - } - - if (strcmp("client", argv[1]) == 0) + // int temp = shm_mm_wrapper_alloc_key(); + // printf("tmp=%d\n", temp); + server(port); + } else if (strcmp("mclient", argv[1]) == 0) { + startClients(port); + } else if (strcmp("client", argv[1]) == 0) { client(port); + } else { + printf("input invalidate arguments\n"); + } return 0; -- Gitblit v1.8.0