From 28f9f739fad7944f64f7df2b8af046f57d50eb8b Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 22 十二月 2020 16:01:34 +0800 Subject: [PATCH] three 信号量 --- test_net_socket/test_net_mod_socket.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/test_net_socket/test_net_mod_socket.c b/test_net_socket/test_net_mod_socket.c index 2277182..1ca04d0 100644 --- a/test_net_socket/test_net_mod_socket.c +++ b/test_net_socket/test_net_mod_socket.c @@ -33,9 +33,34 @@ void * client; +void *proxy_server_handler(void *sockt) { + pthread_detach(pthread_self()); + + char action[512]; + while ( true) { + printf("Input action: Close?\n"); + if(scanf("%s",action) < 1) { + printf("Invalide action\n"); + continue; + } + + if(strcmp(action, "close") == 0) { + net_mod_server_socket_close(sockt); + shm_mm_wrapper_destroy(); + break; + } else { + printf("Invalide action\n"); + } + } +} + void start_net_proxy(int port) { + pthread_t tid; printf("Start net proxy\n"); void *serverSocket = net_mod_server_socket_open(port); + + // 鍒涘缓涓�涓嚎绋�,鍙互鍏抽棴server + pthread_create(&tid, NULL, proxy_server_handler, serverSocket); if(net_mod_server_socket_start(serverSocket) != 0) { err_exit(errno, "net_mod_server_socket_start"); } @@ -432,6 +457,9 @@ } + printf("==========end========\n"); + shm_mm_wrapper_destroy(); + } -- Gitblit v1.8.0