Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Linux embedded device Qt5.3/5.6 QTcpServer does not emit the newConnection() signal,accept() returns UnsupportedSocketOperationError or UnknownSocketError.
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.
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!!!
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
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?
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.
Are you trying to connect two applications built with different versions of Qt ?
@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=
It seems to be correct.
Can you run the server on your desktop and the client on your device ? Does it work ?
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::listen(8001, "192.168.20.62") == true (listening on port 8001)
QNativeSocketEngine::accept() in !
do accept4 fd:-1!
I wonder why it uses accept4() instead of accept().Amazing....
So,let me find the point....
lanlan last edited by
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.
What kernel version are you running ?
Any parameter specific to that board ?
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);
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.
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 ?
lanlan last edited by
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.
In what way did you modify the code ?