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. QTcpServer newConnection signal is not emitted, even after the connected signal is emitted on the clients QTcpSocket

QTcpServer newConnection signal is not emitted, even after the connected signal is emitted on the clients QTcpSocket

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    m1smr
    wrote on last edited by
    #1

    Server:

    m_server = new QTcpServer(this);
    connect( m_server, SIGNAL( newConnection() ), this, SLOT( client_connected() ) );
    
    if (m_server->listen(QHostAddress::Any, 55556) == false)
    {
    	logger.log("Server failed to listen to port 55556");
    }
    

    Client:

    m_socket = new QTcpSocket();
    connect( m_socket, SIGNAL( connected() ), this , SLOT( connected_to_server() ) );
    
    m_socket->connectToHost(address, 55556);
    

    The clients QTcpSocket connected SIGNAL gets emitted and connected_to_server gets called, but on the server side the SIGNAL newConnection does not get emitted!

    Port is not used, firewall exception is active on both sides, event loop exists

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

      Hi,

      Are you running the client and server on the same machine ?
      What version of Qt are you using ?
      If using Qt 5, you should change your connection statement and use the new style using function pointers, that will give you compile errors in case you have an error in your methods name.

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

      M 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Are you running the client and server on the same machine ?
        What version of Qt are you using ?
        If using Qt 5, you should change your connection statement and use the new style using function pointers, that will give you compile errors in case you have an error in your methods name.

        M Offline
        M Offline
        m1smr
        wrote on last edited by
        #3

        @SGaist Hi,

        I tried it on the same and on different machines.
        I use Qt 4.8.2.
        Do you mean SLOT( &classname::function_name ) instead of SLOT( function_name() ) ?

        thanks

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

          That's not that. Please read the Signals & Slots chapter of Qt's documentation. However, as already stated, it's only valid for Qt 5.

          Before going further, are you locked to that outdated version of Qt ? If so, can you at least update to Qt 4.8.7 which is the latest and last version of the Qt 4 series.

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

          M 1 Reply Last reply
          2
          • SGaistS SGaist

            That's not that. Please read the Signals & Slots chapter of Qt's documentation. However, as already stated, it's only valid for Qt 5.

            Before going further, are you locked to that outdated version of Qt ? If so, can you at least update to Qt 4.8.7 which is the latest and last version of the Qt 4 series.

            M Offline
            M Offline
            m1smr
            wrote on last edited by
            #5

            @SGaist I think I can update to the newest version without a big problem, so I will try that.

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

              Unless you are locked to the Qt 4 series, you should move to Qt 5.12.

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

              M 1 Reply Last reply
              2
              • SGaistS SGaist

                Unless you are locked to the Qt 4 series, you should move to Qt 5.12.

                M Offline
                M Offline
                m1smr
                wrote on last edited by
                #7

                @SGaist I updated both the client and server project to Qt 5.12 and now it works! Thank you!

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

                  Good !

                  Then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

                  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

                  • Login

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