| | |
| | | } |
| | | |
| | | |
| | | void *run_recv2(void *skptr) { |
| | | void *run_recv(void *skptr) { |
| | | pthread_detach(pthread_self()); |
| | | void *recvbuf; |
| | | int size; |
| | |
| | | while (true) { |
| | | printf("run_recv before\n"); |
| | | |
| | | rv = sk->recvfrom_timeout( &recvbuf, &size, &key, &timeout); |
| | | // rv = sk->recvfrom_timeout( &recvbuf, &size, &key, &timeout); |
| | | rv = sk->recvfrom( &recvbuf, &size, &key); |
| | | if(rv == 0) { |
| | | printf("收到订阅消息:%s\n", recvbuf); |
| | | free(recvbuf); |
| | |
| | | |
| | | } |
| | | |
| | | void *run_recv(void *skptr) { |
| | | void *run_recv2(void *skptr) { |
| | | pthread_detach(pthread_self()); |
| | | while(true) { |
| | | logger->debug("================run_recv\n"); |
| | | sleep(1); |
| | | // sleep(1); |
| | | } |
| | | } |
| | | |
| | |
| | | while (true) { |
| | | //printf("Usage: pub <topic> [content] or sub <topic>\n"); |
| | | printf("Can I help you? sub, pub, desub or quit %d\n", i++); |
| | | // sleep(100); |
| | | scanf("%s", action); |
| | | |
| | | printf("client 1\n"); |
| | | // scanf("%s", action); |
| | | std::cin >> action; |
| | | printf("client 2\n"); |
| | | if(strcmp(action, "sub") == 0) { |
| | | printf("Please input topic!\n"); |
| | | scanf("%s", topic); |