src/mako/application/cli/commands/server/Server.php
protected function findAvailablePort(int $port): ?int
	{
		$attempts = 0;

		while($attempts++ < static::MAX_PORTS_TO_TRY)
		{
			if(($socket = @fsockopen('localhost', $port, $errorNumber, $errorString, 0.1)) === false)
			{
				return $port;
			}

			fclose($socket);

			$port++;
		}

		return null;
	}
protected function findAvailablePort(int $port): ?int
	{
		$attempts = 0;

		while($attempts++ < static::MAX_PORTS_TO_TRY)
		{
			if(($socket = @fsockopen('localhost', $port, $errorNumber, $errorString, 0.1)) === false)
			{
				return $port;
			}

			fclose($socket);

			$port++;
		}

		return null;
	}
protected function findAvailablePort ( int $ port ) : ? int { $ attempts = 0 ; while ( $ attempts ++ < static :: MAX_PORTS_TO_TRY ) { if ( ( $ socket = @ fsockopen ( 'localhost' , $ port , $ errorNumber , $ errorString , 0.1 ) ) === false ) { return $ port ; } fclose ( $ socket ) ; $ port ++ ; } return null ; }
Tries to find an avaiable port closest to the desired port.

@param  int      $port Desired port number
@return int|null
Tries to find an avaiable port closest to the desired port .