| | |
| | | long i = 0; |
| | | while (true) { |
| | | //printf("Usage: pub <topic> [content] or sub <topic>\n"); |
| | | printf("Can I help you? sub, pub or quit\n"); |
| | | printf("Can I help you? sub, pub, desub or quit\n"); |
| | | scanf("%s",action); |
| | | |
| | | if(strcmp(action, "sub") == 0) { |
| | |
| | | printf("Sub success!\n"); |
| | | } else { |
| | | printf("Sub failture!\n"); |
| | | exit(0); |
| | | } |
| | | |
| | | } else if(strcmp(action, "desub") == 0) { |
| | | printf("Please input topic!\n"); |
| | | scanf("%s", topic); |
| | | if (dgram_mod_desub(socket, topic, strlen(topic), port) == 0) { |
| | | printf("Desub success!\n"); |
| | | } else { |
| | | printf("Desub failture!\n"); |
| | | exit(0); |
| | | } |
| | | |
| | |
| | | } else if(strcmp(action, "quit") == 0) { |
| | | break; |
| | | } else { |
| | | printf("error input\n"); |
| | | printf("error input argument\n"); |
| | | continue; |
| | | } |
| | | |