QTcpSocket Connection Problem from Different Compiler?
-
I have server - client appliaction Using QTcpsocket TCP layer.
Server is compiled by MSVC x64
client Mingw x86if Server Side compiled by MinGW x86 everything okay but when start compiled by msvc x64 no socket connection incoming server side and client always gives connection socket messages?
what is wrong?
-
and client always gives connection socket messages?
what is wrong?What are the messages?
-
MEssage is ```
"QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "127.0.0.1""and waiting forever.
-
@cemaldemir07
Well, perhaps you shouldn't callconnectToHost
on an open/connecting socket, that's what the message basically says. -
but this is code running MinGW well, when Connect Server Button clicked socket connection is successfully,
in server that msvc 2013 x64 compiled, when clicked connect server button, waiting to connect server and and after some time if doesn not connection triggered i cliked again that (above) message occured.
-
@cemaldemir07
Could you try the fortune client and fortune server examples (again one with mingv the other with MSVC).
http://doc.qt.io/qt-5/qtnetwork-fortuneclient-example.html
http://doc.qt.io/qt-5/qtnetwork-fortuneserver-example.htmlIf they work okay, I'd advise focusing on your own code.
-
Fortne client Server Example works well, in Example
connect(networkSession, &QNetworkSession::opened, this, &Server::sessionOpened);
in my code:
class MyServer : public QTcpServer { Q_OBJECT public: explicit MyServer(QObject *parent = 0); void StartServer(); public slots: protected: void incomingConnection(int socketDescriptor){ qDebug() << "INCOMING CONNECTION"; } private: int ConnectedClientCount; };
may above make a different for example?
-
@cemaldemir07
You should do something with the socket descriptor, otherwise you hang the client. Do you want to make a threaded tcp server, because that'd be the only reason to overrideQTcpServer::incomingConnection
? -
I made my project with multithreading tcp server and everything go on well but problem is made by 32 application that causes a bad_alloc sometimes. I want to server application is be x64 base. I have started my project fourteen mounths ago. I can not change everything if reduce problem with maximum code changing.
-
Hi,
bad_alloc ? How much memory is your application supposed to use ?
-
actually my application is required low memory but the in the life time may be I forgetten a pointer that allocated before from memory causes a crash. I think the solution is using x64 for more stable but not exact solution.
-
@cemaldemir07 said:
I think the solution is using x64 for more stable but not exact solution.
No. If you have a bug in the 32 bit version, switching to 64 bits will not change that. You need to apply yourself, find the problem and ultimately fix it.