在Wireshark中看不到从QUdpSocket发送的数据包

时间:2019-05-23 22:12:58

标签: c++ qt wireshark qudpsocket

我正在尝试在Wireshark中查看我的传出UDP流量。

我创建了新的套接字,并将其绑定到我的QHostAddress :: LocalHost,没有错误。然后,我发送了一些数据writeDatagram,并且返回值正确,但是在Wireshark中看不到任何传出流量。

// create a socket called from init() 
socket = new QUdpSocket(this);
bool ret = socket->bind(QHostAddress::LocalHost, 47000);
if (ret == false)
   {
    printf("failed to bind socket\n");
   }    


// create and sent some data called from send()
QHostAddress addr("192.168.5.12"); // addr of my other computer
qint64 size = socket->writeDatagram(QByteArray("udp data"),addr,47000);

printf("sent %d\n",size); // correct size sent 8

我检查了防火墙设置,如果将其关闭,则结果相同。

1 个答案:

答案 0 :(得分:0)

通过将QHostAddress从localhost更改为分配的路由器地址来解决。