[SOLVED] QTcpServer::listen randomly fails
-
Hi,
I am looking for some clues why QTcpServer::listen (apparently) randomly fails. I am using Ubuntu 64bit 14.04, Qt5.3.2
I am listening on localhost:50000. From the command line I can see that this address is free, however sometimes QTcpServer::listen just fails.
Has anyone ever encountered this? Or can anyone point me in the right direction?
Greetings,
t3685
-
What is the error it throws ? Are u restarting your server frequently ?
-
Hi,
The server is started right after boot up, I check for the return value of listen and see that it is false. I don't know see any other errors, unless I missed something. Is there a way to get more detailed information as to why it would fail?
-
-
It seems I have been blind :-)
-
when the bind fails, just call QTCPServer.errorString(...). This will return the last error occurred. I'm suspecting either your interfaces are not up when you give bind or port you are binding is already used by some other process. errorString() should clear the dust.
-
Hi,
Sorry for re-opening this. I am getting QAbstractSocket::AddressInUseError at bootup. Subsequent attempts to are successful. Has anyone come across something like this before?
Greetings,
t3685
-
Port you are specifying might have used by other process before your program binds or your program itself may be doing the bind twice within short interval. I suspect the first issue.
-
I have tried using different ports, but the same result. I will check whether my server is not calling listen twice.
-
I fixed the problem by switching for using a QApplication object in my main function to a QCoreApplication.