Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTcpSocket Connection Problem from Different Compiler?
QtWS25 Last Chance

QTcpSocket Connection Problem from Different Compiler?

Scheduled Pinned Locked Moved Unsolved General and Desktop
mingwmsvc x64qt 5.5.1qtcpsocketqtcpserver
12 Posts 3 Posters 6.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cemaldemir07C Offline
    cemaldemir07C Offline
    cemaldemir07
    wrote on last edited by cemaldemir07
    #1

    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?

    kshegunovK 1 Reply Last reply
    0
    • cemaldemir07C cemaldemir07

      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?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @cemaldemir07

      and client always gives connection socket messages?
      what is wrong?

      What are the messages?

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • cemaldemir07C Offline
        cemaldemir07C Offline
        cemaldemir07
        wrote on last edited by cemaldemir07
        #3

        MEssage is ```
        "QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "127.0.0.1""

        
        and waiting forever.
        kshegunovK 1 Reply Last reply
        0
        • cemaldemir07C cemaldemir07

          MEssage is ```
          "QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "127.0.0.1""

          
          and waiting forever.
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @cemaldemir07
          Well, perhaps you shouldn't call connectToHost on an open/connecting socket, that's what the message basically says.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • cemaldemir07C Offline
            cemaldemir07C Offline
            cemaldemir07
            wrote on last edited by
            #5

            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.

            kshegunovK 1 Reply Last reply
            0
            • cemaldemir07C cemaldemir07

              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.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

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

              If they work okay, I'd advise focusing on your own code.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • cemaldemir07C Offline
                cemaldemir07C Offline
                cemaldemir07
                wrote on last edited by
                #7

                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?

                kshegunovK 1 Reply Last reply
                0
                • cemaldemir07C cemaldemir07

                  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?

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #8

                  @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 override QTcpServer::incomingConnection?

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • cemaldemir07C Offline
                    cemaldemir07C Offline
                    cemaldemir07
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Hi,

                      bad_alloc ? How much memory is your application supposed to use ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • cemaldemir07C Offline
                        cemaldemir07C Offline
                        cemaldemir07
                        wrote on last edited by cemaldemir07
                        #11

                        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.

                        kshegunovK 1 Reply Last reply
                        0
                        • cemaldemir07C cemaldemir07

                          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.

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on last edited by
                          #12

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

                          Read and abide by the Qt Code of Conduct

                          1 Reply Last reply
                          3

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved