| | |
| | | unsigned short port = *(unsigned short*)(out); |
| | | copy_memory(reply, reply_len, (char*)out + port_size, out_len - port_size); |
| | | BHFree(out, out_len); |
| | | printf("======>> recv port %d\n", port); |
| | | // printf("======>> recv port %d\n", port); |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | const auto& url_pub_proxy = get_url(URLPubProxy); |
| | |
| | | if (addr.ParseFromArray(remote, remote_len)){ |
| | | if (!addr.ip().empty() && addr.port() > 0){ |
| | | url = "tcp://" + addr.ip() + ":" + to_string(addr.port()); |
| | | printf("======>> BHRequest use remote address %s\n", url.c_str()); |
| | | // printf("======>> BHRequest use remote address %s\n", url.c_str()); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (addr.ParseFromArray(remote, remote_len)){ |
| | | if (!addr.ip().empty() && addr.port() > 0){ |
| | | url = "tcp://" + addr.ip() + ":" + to_string(addr.port()); |
| | | printf("======>> BHRequest use remote address %s\n", url.c_str()); |
| | | // printf("======>> BHRequest use remote address %s\n", url.c_str()); |
| | | } |
| | | } |
| | | } |
| | |
| | | rc = nn_recv(pub->socket_, &tmp, NN_MSG, 0); |
| | | if (rc > 0){ |
| | | nn_freemsg(tmp); |
| | | printf("======>> publish topic %s data length %lu\n", msg->topic_.c_str(), msg->data_.size()); |
| | | // printf("======>> publish topic %s data length %lu\n", msg->topic_.c_str(), msg->data_.size()); |
| | | lock_guard<mutex> l{pub->mtx_msg_}; |
| | | pub->msg_.pop_front(); |
| | | continue; |
| | |
| | | } |
| | | } |
| | | } |
| | | printf("======>> subscribe recv topic %s msg length %lu\n", topic, msg.length()); |
| | | // printf("======>> subscribe recv topic %s msg length %lu\n", topic, msg.length()); |
| | | if (!msg.empty()){ |
| | | lock_guard<mutex> l(sub->mtx_msg_); |
| | | sub->msg_.emplace_back(topic, move(msg)); |
| | |
| | | get<1>(get<1>(rep->socks_)) = port; |
| | | ipc = "tcp://0.0.0.0:" + to_string(port); |
| | | if(create_server(&get<0>(get<1>(rep->socks_)), ipc, 62, rep) != 0) return -1; |
| | | printf("======>> create server for remote port %d\n", port); |
| | | // printf("======>> create server for remote port %d\n", port); |
| | | }else { |
| | | get<0>(get<1>(rep->socks_)).id = numeric_limits<int32_t>::max(); |
| | | } |