Unable to connect a socket with QTcpSocket...
-
I'm trying to make a program that connects to websites. I just want the connect to succeed or fail.
Here is a trimmed down example that fails. The Signal slots are never called.It is based on this example: http://doc.qt.nokia.com/4.7/network-fortuneclient.html
Here is my trimmed down example - source code etc.
http://www.windyweather.net/wp/2011/01/05/qtcpsocket-unable-to-connect/Can you see what I am doing wrong?
Thanks,
Windy -
If you switch your code to:
@
// connect the tcp socket to our routines
connect( &m_tcpSocket, SIGNAL(connected()), this, SLOT(siteConnected()));
@instead of
@
// connect the tcp socket to our routines
connect( &m_tcpSocket, SIGNAL(readyRead()), this, SLOT(siteConnected()));
@it works.
You use readRead() if the other part of the connection is sending data to you, but that's not what you want in the example.
If you look at the documentation for "QAbstractSocket::connectToHost":http://doc.qt.nokia.com/latest/qabstractsocket.html#connectToHost it's tsated, that the connected signal is emitted.
-
Ok thanks. That would certainly explain it. I'll give that a try and get back.
Thanks much,
Windy