| | |
| | | if(strcmp(action, "sub") == 0) { |
| | | printf("Please input topic!\n"); |
| | | scanf("%s", topic); |
| | | dgram_mod_sub(socket, topic, strlen(topic), port); |
| | | printf("Sub success!\n"); |
| | | if (dgram_mod_sub(socket, topic, strlen(topic), port) == 0) { |
| | | printf("Sub success!\n"); |
| | | } else { |
| | | printf("Sub failture!\n"); |
| | | exit(0); |
| | | } |
| | | |
| | | } |
| | | else if(strcmp(action, "pub") == 0) { |
| | | // printf("%s %s %s\n", action, topic, content); |
| | | printf("Please input topic and content\n"); |
| | | scanf("%s %s", topic, content); |
| | | dgram_mod_pub(socket, topic, strlen(topic)+1, content, strlen(content)+1, port); |
| | | printf("Pub success!\n"); |
| | | if(dgram_mod_pub(socket, topic, strlen(topic)+1, content, strlen(content)+1, port) == 0){ |
| | | printf("Pub success!\n"); |
| | | } else { |
| | | printf("Pub failture!\n"); |
| | | } |
| | | |
| | | } else if(strcmp(action, "quit") == 0) { |
| | | break; |
| | | } else { |