Modified the logic to check Port is in use for runtime. Fixes #5751.

This commit is contained in:
Akshay Joshi 2020-09-03 19:21:54 +05:30
parent eaa90ee8eb
commit 9ae9ccff16

View File

@ -346,11 +346,15 @@ bool Runtime::isPortInUse(const quint16 port) const
{ {
QTcpSocket socket; QTcpSocket socket;
// Bind the socket on the specified port. It it fails then // Bind the socket on the specified port.
// port is in use. socket.bind(port, QTcpSocket::DontShareAddress);
bool bindSuccessful = socket.bind(port, QTcpSocket::ShareAddress);
return !bindSuccessful; // Returns the host port number of the local socket if available; otherwise returns 0
quint16 tmpPort = socket.localPort();
if (tmpPort == 0)
return true;
return false;
} }
void Runtime::openConfigureWindow(const QString errorMsg) void Runtime::openConfigureWindow(const QString errorMsg)