From 0cb4f2b1acb16c1ee1bd86a40116300ea2e2cdaa Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 26 一月 2021 10:18:30 +0800 Subject: [PATCH] update --- test_net_socket/test_net_mod_socket.cpp | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/test_net_socket/test_net_mod_socket.cpp b/test_net_socket/test_net_mod_socket.cpp index c5092e9..a1a47ec 100644 --- a/test_net_socket/test_net_mod_socket.cpp +++ b/test_net_socket/test_net_mod_socket.cpp @@ -2,7 +2,7 @@ #include "net_mod_socket_wrapper.h" #include "bus_server_socket_wrapper.h" -#include "shm_mm_wraper.h" +#include "shm_mm_wrapper.h" #include "usg_common.h" #include <getopt.h> @@ -76,10 +76,13 @@ void *recvbuf; int size; int key; - while (net_mod_socket_recvfrom( sockt, &recvbuf, &size, &key) == 0) { + int rv; + while ((rv = net_mod_socket_recvfrom( sockt, &recvbuf, &size, &key) ) == 0) { printf("鏀跺埌璁㈤槄娑堟伅:%s\n", recvbuf); free(recvbuf); } + + printf("print_sub_msg return . rv = %d\n", rv); } @@ -187,7 +190,8 @@ if (fgets(content, MAXLINE, stdin) != NULL) { // 鏀跺埌娑堟伅鐨勮妭鐐瑰嵆浣挎病鏈夊搴旂殑淇℃伅锛� 涔熻鍥炲涓�涓〃绀烘棤鐨勬秷鎭�,鍚﹀垯浼氫竴鐩寸瓑寰� - n = net_mod_socket_sendandrecv(client, node_arr, node_arr_size, content, strlen(content), &recv_arr, &recv_arr_size); + // n = net_mod_socket_sendandrecv(client, node_arr, node_arr_size, content, strlen(content), &recv_arr, &recv_arr_size); + n = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, content, strlen(content), &recv_arr, &recv_arr_size, 1000); printf(" %d nodes reply\n", n); for(i=0; i<recv_arr_size; i++) { printf("host:%s, port: %d, key:%d, content: %s\n", @@ -247,7 +251,7 @@ net_mod_recv_msg_t *recv_arr; int total = 0; - + void *client = net_mod_socket_open(); net_node_t *node_arr; int node_arr_size = parse_node_list(targ->nodelist, &node_arr); @@ -264,8 +268,8 @@ sprintf(sendbuf, "thread(%d) %d", targ->id, i); fprintf(fp, "requst:%s\n", sendbuf); // n = net_mod_socket_sendandrecv(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf) + 1, &recv_arr, &recv_arr_size); - n = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf) + 1, &recv_arr, &recv_arr_size, 1000); - printf("send %d nodes\n", n); + n = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf) + 1, &recv_arr, &recv_arr_size, 1000); + printf("%d: send %d nodes\n", i, n); for(j=0; j < recv_arr_size; j++) { fprintf(fp, "reply: host:%s, port: %d, key:%d, content: %s\n", recv_arr[j].host, @@ -279,7 +283,7 @@ total += n; } fclose(fp); - + net_mod_socket_close(client); return (void *)total; } @@ -294,7 +298,7 @@ struct timeval start, end; long total = 0; - client = net_mod_socket_open(); + printf("寮�濮嬫祴璇�...\n"); gettimeofday(&start, NULL); for (i = 0; i < processors; i++) { @@ -319,7 +323,7 @@ long diffusec = difftime - diffsec*1000000; fprintf(stderr,"鍙戦�佹暟鐩�: %ld, 鐢ㄦ椂: (%ld sec %ld usec), 骞冲潎: %f\n", total, diffsec, diffusec, difftime/total ); // fflush(stdout); - net_mod_socket_close(client); + } -- Gitblit v1.8.0