[英]Qt UDP can't read data
I try to write a simple Multicast UDP receiver.我尝试编写一个简单的多播 UDP 接收器。
I can receive data when the Internet is not available, but not when it is available.我可以在 Internet 不可用时接收数据,但在可用时则不能。
In Wireshark, Data is received in either state.在 Wireshark 中,数据以任一状态接收。
m_pUdpSockRecv = new QUdpSocket(this);
m_pUdpSockRecv->bind( QHostAddress("192.168.0.254") ,usPort, QUdpSocket::ShareAddress );
m_pUdpSockRecv->joinMulticastGroup( QHostAddress("239.0.0.20") );
connect(m_pUdpSockRecv, SIGNAL(readyRead()), this, SLOT( fnUdpRecvData() ));
I think readyRead() is not called,but I can't solved this problem.我认为 readyRead() 没有被调用,但我无法解决这个问题。
I want to be connected Internet and UDP at the same time.Because I'm getting source from Internet.我想同时连接 Internet 和 UDP。因为我从 Internet 获取源。
Sorry, I solved.对不起,我解决了。
m_pUdpSockRecv = new QUdpSocket(this);
connect(m_pUdpSockRecv, SIGNAL(readyRead()), this, SLOT( fnUdpRecvData() ));
m_pUdpSockRecv->bind( QHostAddress("192.168.0.254") ,usPort, QUdpSocket::ShareAddress );
m_pUdpSockRecv->joinMulticastGroup( QHostAddress("239.0.0.20") );
This code is connected.此代码已连接。
It problem is position of [connect].问题是[连接]的位置。
[connect] should have been before [bind]. [connect] 应该在 [bind] 之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.