| | |
| | | net_mod_recv_msg_t *recv_arr; |
| | | while (true) { |
| | | sprintf(sendbuf, "%d", i); |
| | | printf("SEND HEART:%s\n", sendbuf); |
| | | rv = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf)+1, NULL, NULL, 1000); |
| | | rv = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf)+1, NULL, NULL, 2000); |
| | | //rv = net_mod_socket_sendandrecv(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf)+1, NULL, NULL); |
| | | printf("SEND HEART:%s, suc nodes = %d\n", sendbuf, rv); |
| | | |
| | | // sleep(1); |
| | | i++; |
| | | } |
| | |
| | | signal(SIGINT, sigint_handler); |
| | | Targ *targ = (Targ *)arg; |
| | | int port = targ->port; |
| | | void *socket = net_mod_socket_open(); |
| | | void *client = net_mod_socket_open(); |
| | | int size; |
| | | char sendbuf[512]; |
| | | long scale = 10; |
| | | long scale = 100000; |
| | | long i = 0; |
| | | net_node_t node_arr[] = {"", 0, 100}; |
| | | int node_arr_size = 1; |
| | |
| | | while (i < scale) { |
| | | sprintf(sendbuf, "%d", i); |
| | | printf("%d SEND HEART:%s\n", targ->id, sendbuf); |
| | | net_mod_socket_sendto(socket, sendbuf, strlen(sendbuf) + 1, port); |
| | | sleep(1); |
| | | net_mod_socket_sendandrecv(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf)+1, NULL, NULL); |
| | | // net_mod_socket_sendto(socket, sendbuf, strlen(sendbuf) + 1, port); |
| | | i++; |
| | | } |
| | | |
| | | net_mod_socket_close(socket); |
| | | net_mod_socket_close(client); |
| | | return (void *)i; |
| | | } |
| | | |
| | | |
| | | void startClients(int port) { |
| | | void mclient(int port) { |
| | | |
| | | int status, i = 0, processors = 100; |
| | | int status, i = 0, processors = 4; |
| | | void *res[processors]; |
| | | Targ *targs = (Targ *)calloc(processors, sizeof(Targ)); |
| | | pthread_t tids[processors]; |
| | |
| | | |
| | | port = atoi(argv[2]); |
| | | |
| | | if (strcmp("server", argv[1]) == 0) { |
| | | if (strcmp("server", argv[1]) == 0) |
| | | server(port); |
| | | } |
| | | |
| | | if (strcmp("client", argv[1]) == 0) |
| | | else if (strcmp("client", argv[1]) == 0) |
| | | client(port); |
| | | else if (strcmp("mclient", argv[1]) == 0) |
| | | mclient(port); |
| | | |
| | | shm_mm_wrapper_destroy(); |
| | | return 0; |