mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	- Increases linker performance under Linux builds by using Gold linker, if available - ccache is used if available - removed statistic class (Stats.cpp) from project due to the missing result (sorry @Brindosch) - add LGTM bandges for code analysis overview Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			826 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			826 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#pragma once
 | 
						|
 | 
						|
#include <utils/Logger.h>
 | 
						|
 | 
						|
#include <QTcpServer>
 | 
						|
 | 
						|
namespace NetUtils {
 | 
						|
	///
 | 
						|
	/// @brief Check if the port is available for listening
 | 
						|
	/// @param[in/out] port  The port to test, will be incremented if port is in use
 | 
						|
	/// @param         log   The logger of the caller to print
 | 
						|
	/// @return        True on success else false
 | 
						|
	///
 | 
						|
	static bool portAvailable(quint16& port, Logger* log)
 | 
						|
	{
 | 
						|
		const quint16 prevPort = port;
 | 
						|
		QTcpServer server;
 | 
						|
		bool corrected = false;
 | 
						|
		while (!server.listen(QHostAddress::Any, port))
 | 
						|
		{
 | 
						|
			corrected = true;
 | 
						|
			Warning(log,"Port '%d' is already in use, will increment", port);
 | 
						|
			port ++;
 | 
						|
		}
 | 
						|
		server.close();
 | 
						|
		if(corrected)
 | 
						|
		{
 | 
						|
			Warning(log, "The requested Port '%d' was already in use, will use Port '%d' instead", prevPort, port);
 | 
						|
			return false;
 | 
						|
		}
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
 | 
						|
}
 |