Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Linux embedded device Qt5.3/5.6 QTcpServer does not emit the newConnection() signal,accept() returns UnsupportedSocketOperationError or UnknownSocketError.
Forum Updated to NodeBB v4.3 + New Features

Linux embedded device Qt5.3/5.6 QTcpServer does not emit the newConnection() signal,accept() returns UnsupportedSocketOperationError or UnknownSocketError.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
13 Posts 3 Posters 1.6k 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.
  • L Offline
    L Offline
    lanlan
    wrote on last edited by lanlan
    #1

    Qt example code on Linux embedded device as server(my own code is the same).Network assist tool on PC as client.I tried running two versions of the Server(Example code),both of them didn't worked.

    note:
    1.My own application and official example can run on the local environment,but not on Linux Embedded device.
    2.by using netstat -an show that the connect is ESTABLISHED,i tried every possible way to fix it(change port,different version Qt,check Firewall,event loop and so on),but all didn't work.
    3.I implemented by Posix C,it worked.

    I have no ideas about it,has anyone encountered the same problem,help me plz!!!

    more info:
    Do netstat -an after client has successfully connected on QTcpServer.The connection is 'ESTABLISHED' but connect(tcpServer, &QTcpServer::acceptError,this,&Server::myError) return QAbstractSocket::UnknownSocketError.So Qt dont emit QTcpServer::newConnection in this case(i had read the Qt source code).

    [root]# ./QtNetworkTest &
    [root]# debug mode
    [root]# myError: QAbstractSocket::UnknownSocketError
    [root]# netstat -na
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address Foreign Address State
    tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
    tcp 1 0 192.168.20.62:8001 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:37 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:7 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:13 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
    tcp 0 0 192.168.20.62:8001 192.168.20.171:24489 ESTABLISHED
    udp 0 0 0.0.0.0:7 0.0.0.0:*
    udp 0 0 0.0.0.0:13 0.0.0.0:*
    udp 0 0 0.0.0.0:37 0.0.0.0:*
    Active UNIX domain sockets (servers and established)
    Proto RefCnt Flags Type State I-Node Path

    STREAM CONNECTED 1731

    STREAM CONNECTED 1730

    J.HilkJ 1 Reply Last reply
    0
    • L lanlan

      Qt example code on Linux embedded device as server(my own code is the same).Network assist tool on PC as client.I tried running two versions of the Server(Example code),both of them didn't worked.

      note:
      1.My own application and official example can run on the local environment,but not on Linux Embedded device.
      2.by using netstat -an show that the connect is ESTABLISHED,i tried every possible way to fix it(change port,different version Qt,check Firewall,event loop and so on),but all didn't work.
      3.I implemented by Posix C,it worked.

      I have no ideas about it,has anyone encountered the same problem,help me plz!!!

      more info:
      Do netstat -an after client has successfully connected on QTcpServer.The connection is 'ESTABLISHED' but connect(tcpServer, &QTcpServer::acceptError,this,&Server::myError) return QAbstractSocket::UnknownSocketError.So Qt dont emit QTcpServer::newConnection in this case(i had read the Qt source code).

      [root]# ./QtNetworkTest &
      [root]# debug mode
      [root]# myError: QAbstractSocket::UnknownSocketError
      [root]# netstat -na
      Active Internet connections (servers and established)
      Proto Recv-Q Send-Q Local Address Foreign Address State
      tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
      tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
      tcp 1 0 192.168.20.62:8001 0.0.0.0:* LISTEN
      tcp 0 0 0.0.0.0:37 0.0.0.0:* LISTEN
      tcp 0 0 0.0.0.0:7 0.0.0.0:* LISTEN
      tcp 0 0 0.0.0.0:13 0.0.0.0:* LISTEN
      tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
      tcp 0 0 192.168.20.62:8001 192.168.20.171:24489 ESTABLISHED
      udp 0 0 0.0.0.0:7 0.0.0.0:*
      udp 0 0 0.0.0.0:13 0.0.0.0:*
      udp 0 0 0.0.0.0:37 0.0.0.0:*
      Active UNIX domain sockets (servers and established)
      Proto RefCnt Flags Type State I-Node Path

      STREAM CONNECTED 1731

      STREAM CONNECTED 1730

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      Hi @lanlan and welcome

      I'm afraid you would need to share some of your code otherwise all anyone can do is take a guess.

      And that's what I will do now.
      90% off the time the reason for "Signal XY is not emitted/slot yz is not called" is due to QThread::sleep calls.

      Do you do that?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lanlan
        wrote on last edited by lanlan
        #3

        @J-Hilk
        Thx for reply very much.
        Never called QThread::sleep().I ran Qt example code in main thread,and it worked on local system,the same as my own code.So I think the reason is not related to code implementation.Maybe it caused by Embedded system configuration or Qt cross-compilation error,but i can not find the point.

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

          Hi,

          Are you trying to connect two applications built with different versions of Qt ?

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

          L 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Are you trying to connect two applications built with different versions of Qt ?

            L Offline
            L Offline
            lanlan
            wrote on last edited by lanlan
            #5

            @SGaist Hi,thank you for the help.

            Qt example code on Linux embedded device as server(my own code is the same).Network assist tool on PC as client.At first,I thought there was something wrong with my implementation,so I tried official example code.Then i tried running two versions Qt of the Server(Example code),both of them didn't work.

            I also used QT_DEBUG_PLUGINS=1,the result is here:

            Found metadata in lib /opt/5.6armQt/plugins/bearer/libqnmbearer.so, metadata=
            {
            "IID": "org.qt-project.Qt.QBearerEngineFactoryInterface",
            "MetaData": {
            "Keys": [
            "networkmanager"
            ]
            },
            "className": "QNetworkManagerEnginePlugin",
            "debug": true,
            "version": 329219
            }

            It seems to be correct.

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

              Can you run the server on your desktop and the client on your device ? Does it work ?

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

              L 1 Reply Last reply
              0
              • SGaistS SGaist

                Can you run the server on your desktop and the client on your device ? Does it work ?

                L Offline
                L Offline
                lanlan
                wrote on last edited by lanlan
                #7

                @SGaist
                I get your point,but I am sure the program is ok.Because it can run on other devices.Maybe the problem caused by linux kernel version,i will deep into Qt source code.

                I debugged source code,log is here:

                QTcpServer::QTcpServer(0xbe9d1b04)
                QTcpServer::listen(8001, "192.168.20.62") == true (listening on port 8001)
                pendingConnections.count(): 0
                maxConnections: 30
                QNativeSocketEngine::accept() in !
                Unix QNativeSocketEnginePrivate::nativeAccept()!
                QT_THREADSAFE_CLOEXEC!
                do accept4 fd:-1!
                acceptedDescriptor: -1
                errno: 94
                descriptor: -1
                myError: QAbstractSocket::UnknownSocketError

                I wonder why it uses accept4() instead of accept().Amazing....

                So,let me find the point....

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lanlan
                  wrote on last edited by
                  #8

                  I used accpet() instead.

                  I dont know the root cause the problem.
                  And I can't predict what the consequences of this modification will be.

                  But the code works fine.

                  So I keep the question and wait for the big one to solve.

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

                    What kernel version are you running ?
                    Any parameter specific to that board ?

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

                    L 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      What kernel version are you running ?
                      Any parameter specific to that board ?

                      L Offline
                      L Offline
                      lanlan
                      wrote on last edited by lanlan
                      #10

                      @SGaist
                      Hi,
                      kernel 3.2.0,using the vendor's kernel image.So i dont know the details.

                      Only know,when using accept(), must specify the length of the third parameter,can not be null or 0(Qt source is 0).Otherwise, it also doesnt work.

                      Source code is here(qnativesocketengine_unix.cpp +561):
                      int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);

                      I almost learned every post related to the issue on the forum, and there is no solution.So i think maybe its a bug of kernel or Qt.It may also be that my ability is not good enough to find the point.

                      Whatever,i have no time to continue it,So the problem is "solved", and waiting for the big one.

                      Btw,if you have the ability to send questions to the Qt Group, it may help more guys.
                      :)

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

                        You can ask the question yourself directly, it's not a closed group ;-)

                        That said, where exactly did you saw that issue with the size in Qt's code ?
                        Did you check whether more recent versions of Qt are still affected ?

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

                        L 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          You can ask the question yourself directly, it's not a closed group ;-)

                          That said, where exactly did you saw that issue with the size in Qt's code ?
                          Did you check whether more recent versions of Qt are still affected ?

                          L Offline
                          L Offline
                          lanlan
                          wrote on last edited by
                          #12

                          @SGaist

                          Hi,
                          Yes,I modified the Qt's code(qnativesocketengine_unix.cpp +561).
                          And my code just ran on version 5.3/5.6.

                          Thanks for the reply.

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

                            In what way did you modify the code ?

                            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
                            0

                            • Login

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