I’m using QT5 and starting out with a basic Server/Client setup. I’m looking at going single threaded for both apps as there is no heavy processing on network data. Now, from everything I’ve read and researched here, when using asynchronous approach, you don’t use waitForXXXX() otherwise it messes up all the signals and slots.
The problem – On the client end, the connected() signal is either never emitted or never processed, even though the server consoles tells me that a new client has connected. I’ve been working on the same issue for 2 weeks now and couldn’t find the exact same issue anywhere. I’ve stripped back both apps to the minimum and still no luck – also stripped out the UI part now – I just want see the console working. I have also tried switching to public slots and changing the signal/slot connection type and still have the same problem.
If you require code from the server, please let me know, but here is the basics of the client:
int main(int argc, char *argv())
freopen( "conin$", "r", stdin );
freopen( "conout$", "w", stdout );
freopen( "conout$", "w", stderr );
QApplication a( argc, argv );
QGameSocket* pSocket = new QGameSocket();
#pragma comment ( lib, "Qt5Network.lib" )
class QGameSocket: public QObject
explicit QGameSocket( QObject* pParent = 0 );
QGameSocket::QGameSocket( QObject* pParent ) :
QObject( pParent )
m_pSocket = new QTcpSocket();
connect( m_pSocket, SIGNAL( connected() ), this, SLOT( __OnConnected() ) );
connect( m_pSocket, SIGNAL( readyRead() ), this, SLOT( __OnReadyRead() ) );
const QString strHost = "127.0.0.1";
qDebug() << "Connecting to host ...";
m_pSocket->connectToHost( strHost, 27015 );
qDebug() << "Successfully connected to host!";
Any help would be much appreciated, thank you!