Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QNetworkSession::Invalid & different IP settings
I'm standing in front of a problem not easy to solve for me as I am not a system admin. My client server application runs perfectly on a system with pure IPv4 configuration. Even my Win7 PC with IPv6 and IPv4 addresses is able to listen correctly on IPv4 - using tcp_server->listen(QHostAddress::Any,2000). The Qt-Doc says, QHostAddress::Any is listening on all IPv4 addresses. Now, I have a special Win7 PC, where I am not able to listen on IPv4 - however it is visible in the Windows network and all windows programms seem not to have communication problems. I always run into QNetworkSession::Invalid. The ipconfig /all looks similar to the Win7 PC and IPv6 config where it runs without errors (at least similar for me). Is there something I need to check in addition? Is there a thing I have to take into account in my code? Any clues or hints would be very much appreciated.
Could it be the firewalling of the windows machine? Even if your application should be able to always listen on an unprivileged port, I guess it has something to do with the firewall. Exluding the trivial case you are listening on the same port another program is using too.
However, as a quick trial, try disabling the firewall at all and see if the situation goes better.
Ok, I will give the Firewall a try.
For my understanding: Is it mandatory in internal networks to announce a proper port? The port 2000 is not really used, when I check it after a valid connection. I always thought that ports are just needed for communication over the internet (outside a domain name area).
It's no required to advice the ports you are using, but it is a good idea to check which ports are already used by some well known services (e.g., /etc/services). And of course, using ports greater than 1024 is another good idea.
We found the error. It is because of strange user settings. When launched as Admin the software is able to aquire network access. So it was not because of Firewall and IPv4/IPv6. However the error is not solved, but root cause seems to be in Windows settings and not in QtNetwork.
Great! So the problem is that the security center of windows believes your application could be malicious and prevents it to open a port.So you have to remember that the application has to be launched with the admin settings.
Wow, I did not know I'm a virus developer...
Do you think there is a way to bypass this check from software side with Qt methods? I currently have the feeling I need to sign my software. But really, I would like to avoid this, as it is not cross platform.
I don't know, since I'm not a windows developer.
However, I suspect this is a feature you cannot easily bypass, since it is something within the hosting operating system. Probably adding exception to the trusted programs could work.