[Qt-interest] readyRead not working (sometimes)

John McClurkin jwm at nei.nih.gov
Wed Nov 25 17:54:06 CET 2009


Dobbs, Paul wrote:
> I have created a C++ class which uses QUdpSocket to set up 
> communications between two programs. I’m using the class in four 
> different programs. Here is the code that creates the socket:
>  
> bool CSugvSocket::CreateUDPSocket(QString sendToIp, quint16 sendToPort, 
> quint16 myPort, CTest1 *parent)
> {
>     m_Parent = parent;
>     m_MyPort = myPort;
>     m_SendToPort = sendToPort;
>     m_SendToIp.setAddress(sendToIp);
>  
>     m_Socket = new QUdpSocket(this);
>  
>     connect(m_Socket, SIGNAL(readyRead()),this, SLOT(on_ReadyRead()));
>  
>     return m_Socket->bind(QHostAddress::LocalHost, m_MyPort);
> }
>  
> The problem is that the socket works in two of the programs and doesn’t 
> work in the other two. In the programs that don’t work, it never 
> receives any packets. I can put a breakpoint in on_ReadyRead, but it is 
> never reached. It is as though the connection didn’t work or was severed 
> somehow or else the readyRead signal was never being sent. I have not 
> been able to figure out a cause. I don’t even know where to start 
> looking. Can someone help?
>  
> I am using Visual Studio 2005 with Qt 4.5.2.

Only with some general advice. How different are the programs that work 
and those that don't? Can you morph one of the working programs into one 
of the non-working programs and see where the socket stops working? Can 
you work backward from one of the non-working programs to the simplest 
possible case and see where the socket starts working?



More information about the Qt-interest-old mailing list