| | |
| | | shm_socket_t *client_socket; |
| | | while(true) { |
| | | client_socket = shm_accept(socket); |
| | | printf("server messageQueue = %p\n", client_socket->messageQueue); |
| | | // printf("server messageQueue = %p\n", client_socket->messageQueue); |
| | | pthread_create(&tid, NULL, precess_client , (void *)client_socket); |
| | | } |
| | | |
| | |
| | | |
| | | int size; |
| | | void *recvbuf; |
| | | printf("requst:%s\n", sendbuf); |
| | | shm_send(socket, sendbuf, strlen(sendbuf)+1) ; |
| | | shm_recv(socket, &recvbuf, &size); |
| | | printf("reply: %s\n", (char *)recvbuf); |
| | |
| | | int scale = 100000; |
| | | int i; |
| | | shm_socket_t *socket = shm_open_socket(); |
| | | |
| | | shm_connect(socket, port); |
| | | for( i = 0; i<scale; i++) { |
| | | sprintf(sendbuf, "processor(%d) %d", targ->id, i); |
| | | sprintf(sendbuf, "thread(%d) %d", targ->id, i); |
| | | |
| | | client_send(socket, sendbuf); |
| | | } |
| | | shm_close_socket(socket); |
| | |
| | | |
| | | void multyThreadClient(int port) { |
| | | |
| | | int status, i = 0, processors = 2; |
| | | int status, i = 0, processors = 4; |
| | | void *res[processors]; |
| | | Targ *targs= (Targ*)calloc(processors, sizeof(Targ)); |
| | | pthread_t tids[processors]; |
| | |
| | | |
| | | if (strcmp("mclient", argv[1]) == 0) |
| | | multyThreadClient(port); |
| | | shm_destroy(); |
| | | |
| | | shm_destroy(); |
| | | // fprintf(stderr, "Usage: reqrep %s|%s <URL> ...\n", "server", "client"); |
| | | return 0; |
| | | } |