Hallo Michael, leider keine Besserung.
Aktuell sieh das Script so aus:
<?php
include_once("../modules/SymconSonos/Sonos/sonosAccess.php");
$msg = 'M-SEARCH * HTTP/1.1' . "
";
$msg .= 'HOST: 255.255.255.255:1900' . "
";
$msg .= 'MAN: "ssdp:discover"' . "
";
$msg .= "MX: 3
";
$msg .= "ST: urn:schemas-upnp-org:device:ZonePlayer:1
";
$msg .= '' . "
";
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, 1);
socket_sendto($socket, $msg, strlen($msg), 0, '255.255.255.255', 1900);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 2, 'usec' => 0));
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
socket_bind($socket, '0.0.0.0', 0);
$res = null;
socket_recvfrom($socket, $res, 1024, 0, $from, $port);
if (!is_null($res)) {
$lines = explode("
", trim($res));
if (trim($lines[0]) == 'HTTP/1.1 200 OK') {
array_shift($lines);
}
foreach ($lines as $line) {
$tmp = explode(':', trim($line));
if ( strtoupper(array_shift($tmp)) === 'LOCATION'){
$value = (count($tmp) > 0 ? trim(join(':', $tmp)) : null);
if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $value, $ip_match)) {
$ip = $ip_match[0];
}
}
}
}
if (!isset($ip)){
die('No Sonos Box found');
}
$sonos = new SonosAccess($ip);
$grouping = new SimpleXMLElement($sonos->GetZoneGroupState());
$zoneGroups = $grouping->ZoneGroups->ZoneGroup;
foreach ($zoneGroups as $zoneGroup){
foreach ($zoneGroup->ZoneGroupMember as $zoneGroupMember){
if ( !isset($zoneGroupMember->attributes()['Invisible']) ) {
if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $zoneGroupMember->attributes()['Location'], $ip_match)) {
$description = new SimpleXMLElement($zoneGroupMember->attributes()['Location'],0,true);
echo $zoneGroupMember->attributes()['UUID'] . " " . $ip_match[0] . " " . $description->device->displayName . " " . $zoneGroupMember->attributes()['ZoneName'] . "
";
}
}
}
}
?>
Fehlermeldung:
Warning: socket_bind(): unable to bind address [10022]: Ein ung�ltiges Argument wurde angegeben.
in C:\IP-Symcon\scripts\25259.ips.php on line 18
Gruß Alex