Unsolved Linux embedded device Qt5.3/5.6 QTcpServer does not emit the newConnection() signal,accept() returns UnsupportedSocketOperationError or UnknownSocketError.
-
@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. -
Hi,
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=
{
"IID": "org.qt-project.Qt.QBearerEngineFactoryInterface",
"MetaData": {
"Keys": [
"networkmanager"
]
},
"className": "QNetworkManagerEnginePlugin",
"debug": true,
"version": 329219
}It seems to be correct.
-
Can you run the server on your desktop and the client on your device ? Does it work ?
-
@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::UnknownSocketErrorI wonder why it uses accept4() instead of accept().Amazing....
So,let me find the point....
-
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 ? -
@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.
:) -
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 ? -
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.
-
In what way did you modify the code ?