wangzhengquan
2021-01-25 6de74d5e60a9a5ecd417a5473a3b567e51ca2de8
test_socket/bus_test.cpp
@@ -23,7 +23,7 @@
}
void *run_recv2(void *skptr) {
void *run_recv(void *skptr) {
  pthread_detach(pthread_self());
  void *recvbuf;
  int size;
@@ -35,7 +35,8 @@
  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);
@@ -48,10 +49,11 @@
  
}
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);
  }
}
@@ -77,9 +79,10 @@
  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);