QTcpSocket Connection Problem from Different Compiler?

  • I have server - client appliaction Using QTcpsocket TCP layer.

    Server is compiled by MSVC x64
    client Mingw x86

    if 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?

  • Qt Champions 2017


    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 """

    and waiting forever.

  • Qt Champions 2017

    Well, perhaps you shouldn't call connectToHost 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.

  • Qt Champions 2017

    Could you try the fortune client and fortune server examples (again one with mingv the other with MSVC).

    If 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
        explicit MyServer(QObject *parent = 0);
        void StartServer();
    public slots:
        void incomingConnection(int socketDescriptor){
        qDebug() << "INCOMING CONNECTION";
        int ConnectedClientCount;

    may above make a different for example?

  • Qt Champions 2017

    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 override QTcpServer::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.

  • Lifetime Qt Champion


    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.

  • Qt Champions 2017

    @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.

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.