RedRat Hub PHP Example Client Code

The few lines of code below open a socket to the hub and uses that to send commands to the irNetBox (with IP address 192.168.1.40):


5, "usec"=>0));

// Connect socket to irNetBox 
if(!socket_connect($sock , $addr , $port))
{
    $errorcode = socket_last_error();
    $errormsg = socket_strerror($errorcode);
    die("Could not connect to RedRatHub $addr:$port - [$errorcode] $errormsg" . PHP_EOL);
}
echo "Connection established to RedRatHub $addr:$port" . PHP_EOL;

// Send Signal Transmission to RedRatHub
sendMessage($sock, "ip=\"192.168.1.40\" dataset=\"Sky+\" signal=\"Channel+\" output=\"1:70\"\n");
sendMessage($sock, "hq=\"list redrats\"\n");
socket_close($sock);

?>