checking whether something in online or not?

Status
Not open for further replies.

cursedpsp

New Member
Messages
237
Reaction score
0
Points
0
Hi i have been looking everywhere around google but i still havent found how to do it,

i got windows media encoder to stream my audio to my website, my location for it is mms://***.***.***.***:5190. Right and i got that transferred to my stream.asx file.

How do i check whether that url is online or not - so far i have tried 8 different codes but its just not working!
Please can somebody help me? Its in PHP by the way.
 

flurgal

New Member
Messages
25
Reaction score
0
Points
0
i got this from the internet somewhere - its just been dumped in my harddrive, give me feedback if it works please
Code:
		<? 
			// Test script. Function created by SecondVersion 
		function is_valid_url($url) 
		{ 
    $url = @parse_url($url); 

    if (!$url) 
    { 
        return false; 
    } 

    $url = array_map('trim', $url); 
    $url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port']; 

    $path = (isset($url['path'])) ? $url['path'] : '/'; 
    $path .= (isset($url['query'])) ? "?$url[query]" : ''; 

    if (isset($url['host']) AND $url['host'] != gethostbyname($url['host'])) 
    { 
        if (PHP_VERSION >= 5) 
        { 
            $headers = implode('', get_headers("$url[scheme]://$url[host]:$url[port]$path")); 
        } 
        else 
        { 
            $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30); 

            if (!$fp) 
            { 
                return false; 
            } 
            fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $url[host]\r\n\r\n"); 
            $headers = fread($fp, 4096); 
            fclose($fp); 
        } 
        return (bool)preg_match('#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers); 
    } 
    return false; 
} 

if(is_valid_url("FILE URL")) 
{ 
    echo("<font color='green'> online</font>"); 
}else{ 
    echo("<font color='red'> offline</font>"); 
}
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
I think this would work:

PHP:
if (fsockopen('mms://***.***.***.***', 5190, $errno, $errstr, 5)) {
    //whatever you want to happen if the server is online
}

Of course you'll have to put your server's IP there instead of the asterisks.

The 5 as the last argument is for a 5 second wait time before canceling. This should be more than enough time to get a response, but you can increase it if you want.
 

cursedpsp

New Member
Messages
237
Reaction score
0
Points
0
I did that and it still says it cant pick it up

the code i am using is
Code:
			if (fsockopen('mms:///82.12.205.111', 5190, $errno, $errstr, 5)) {
				echo "<font color='green'>Online</font>";
			}  
			else{
				echo "<font color='red'>Offline</font>";
			}

It just keeps on saying offline

Edit:
Can i just ask what '$errno' and '$errstr' mean?
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
They store the error number and error string returned. You have to pass variables there in order to set the timeout since the function requires a reference if the parameters are given.

But anyway, it looks like php just doesn't support the mms protocol by default.

http://www.php.net/manual/en/transports.php

So my suggestion would be, provided that you own the server, to have it accept http connections as well.
 
Status
Not open for further replies.
Top