wangzhengquan
2021-01-18 71c847e99c0ce99fae955b08c0aafecb0fb9bdd6
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>
@@ -187,7 +187,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 +248,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);
 
@@ -279,7 +280,7 @@
    total += n;
  }
  fclose(fp);
  net_mod_socket_close(client);
  return (void *)total;
}
@@ -294,7 +295,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 +320,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);
}