wangzhengquan
2020-08-05 ddbeeaaffeab5bc997a0b7a7e8dcac863610feee
test_socket/dgram_mod_bus.c
@@ -10,8 +10,9 @@
}
void server(int port, bool restart) {
 // signal(SIGINT,  sigint_handler);
  signal(SIGINT,  sigint_handler);
  server_socket = dgram_mod_open_socket();
  if(restart) {
    dgram_mod_force_bind(server_socket, port);
@@ -54,15 +55,24 @@
    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 {