For windows I parse 'netstat -n'
Here is PHP code:
Code: Select all
<?php
function netstat($ipaddr,$port,$show=0,$protocol="TCP")
{
$shell_info=shell_exec("%SYSTEMROOT%\\system32\\netstat.exe -n");
$tmp=explode("\n",$shell_info); $count=0;
for ($i=4;$i<count($tmp)-1;$i++)
{
$line=$tmp[$i];
ereg (" +([A-Z]+) +([0-9,.]+):([0-9]+) +([0-9,.]+):([0-9]+) +([A-Z]+)", $line, $regs);
if ($regs[6]!="ESTABLISHED") continue;
if ($regs[1]!=$protocol) continue;
if ($ipaddr&&$regs[2]!=$ipaddr) continue;
if ($port&&$regs[3]!=$port) continue;
++$count;
if ($show)
echo $regs[4]./*":".$regs[5].*/"<br>";
}
return $count;
}
?>
So if you stream to 'UDP://192.168.0.1:1234' try this:
$n=netstat('192.168.0.1',1234,0,'UDP');
or if you want to output ip-list:
$n=netstat('192.168.0.1',1234,1,'UDP');
where
$n is count of listeners.
Use default TCP for http or mmsh streaming:
$n=netstat('192.168.0.1',1234);