public static function isPortInUse($port, $hostname = null)
    {
        $fp = @fsockopen($hostname !== null ? $hostname : '127.0.0.1', $port, $errno, $errstr, 10);
        if ($fp !== false) {
            fclose($fp);

            return true;
        }

        return false;
    }
public static function isPortInUse($port, $hostname = null)
    {
        $fp = @fsockopen($hostname !== null ? $hostname : '127.0.0.1', $port, $errno, $errstr, 10);
        if ($fp !== false) {
            fclose($fp);

            return true;
        }

        return false;
    }
public static function isPortInUse ( $ port , $ hostname = null ) { $ fp = @ fsockopen ( $ hostname !== null ? $ hostname : '127.0.0.1' , $ port , $ errno , $ errstr , 10 ) ; if ( $ fp !== false ) { fclose ( $ fp ) ; return true ; } return false ; }
Check whether a port is open.

@param int         $port
@param string|null $hostname

@return bool
Check whether a port is open .