Jderusse\Warmup\Compiler\PhpServerCompiler::isPortAvailable PHP Method

isPortAvailable() private method

private isPortAvailable ( integer $port ) : boolean
$port integer
return boolean
    private function isPortAvailable(int $port) : bool
    {
        $h = null;
        try {
            $h = socket_create_listen($port);
            if ($h !== false) {
                return true;
            }
        } catch (\ErrorException $e) {
            // just ignore exception port already in use
        } finally {
            if (is_resource($h)) {
                socket_close($h);
            }
        }
        return false;
    }