You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C++与GnuRadio通过ZeroMQ REQ通信失败问题求助

问题:C++ ZeroMQ代码无法向GnuRadio流图发送消息并显示

问题概述

我编写了C++代码通过ZeroMQ向GnuRadio流图发送字符串做测试,但GnuRadio的Message Debug模块始终无法显示消息。抓包确认消息已发送,用nc命令发送也存在同样问题,只有通过另一个GnuRadio流图的ZMQ REP Message Sink发送时,才能看到消息内容。

C++测试代码

#include <zmq.hpp>
#include <iostream>
#include <string>

int main() {
    // Create a ZeroMQ context and a REQ socket
    zmq::context_t context(1);
    zmq::socket_t socket(context, zmq::socket_type::req);
    socket.connect("tcp://127.0.0.1:55555");  // Ensure this matches GNU Radio's address
   
    std::string msg_content = "Hello World";

    // Create a ZeroMQ message with the content
    zmq::message_t request(msg_content.size());
    memcpy(request.data(), msg_content.c_str(), msg_content.size());

    // Send the message to GNU Radio
    socket.send(request, zmq::send_flags::none);

    // Receive the reply from GNU Radio (required for REQ socket)
    zmq::message_t reply;
    socket.recv(reply);

    return 0;
}

GnuRadio流图配置

  • 流图包含两个模块:ZMQ REQ Message Source 连接 Message Debug
  • ZMQ REQ Message Source 的地址设置为 tcp://127.0.0.1:55555

排查细节

  • 通过TCP抓包确认:C++代码和echo "Hello, World!" | nc 127.0.0.1 55555命令均已成功发送"Hello World"字符串
  • 唯一能正常显示的场景:创建另一个GnuRadio流图,用ZMQ REP Message Sink向目标流图发送消息时,Message Debug模块能显示内容

内容的提问来源于stack exchange,提问作者raff5184

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 05:33:29