From e4130d29e80a40884310481ded90ff845c614f43 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期四, 24 十二月 2020 10:03:14 +0800
Subject: [PATCH] bus force bind

---
 test_net_socket/test_net_mod_socket.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/test_net_socket/test_net_mod_socket.c b/test_net_socket/test_net_mod_socket.c
index f509e2c..2b2a56a 100644
--- a/test_net_socket/test_net_mod_socket.c
+++ b/test_net_socket/test_net_mod_socket.c
@@ -85,7 +85,7 @@
 
 
 void *bus_handler(void *sockt) {
-  pthread_detach(pthread_self());
+  // pthread_detach(pthread_self());
   
   char action[512];
   while ( true) {
@@ -119,6 +119,10 @@
     printf("start bus failed\n");
     exit(1);
   }
+
+  if (pthread_join(tid, NULL) != 0) {
+    perror(" pthread_join");
+  }
 }
 
  
@@ -137,6 +141,7 @@
     sprintf(sendbuf, "RECEIVED  PORT %d NAME %s", remote_port, recvbuf);
     net_mod_socket_sendto(client, sendbuf, strlen(sendbuf) + 1, remote_port);
     free(recvbuf);
+    sleep(1000);
   }
 }
 
@@ -259,8 +264,9 @@
   for (i = 0; i < SCALE; i++) {
     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);
-    //printf("send %d nodes\n", n);
+    // 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);
     for(j=0; j < recv_arr_size; j++) {
     	fprintf(fp, "reply: host:%s, port: %d, key:%d, content: %s\n", 
     		recv_arr[j].host,

--
Gitblit v1.8.0