}
                socket_close($ary[1]);
            } else {
                // I am child  - do stuff required and then die
                //var_dump($remote_ip);
                //var_dump($authDevices);
                if (in_array($remote_ip, $authDevices) == true) {
                    $authok = true;
                    //check that the IP address has been authenticated
                    //var_dump($authok);
                } else {
                    $authok = false;
                    //var_dump($authok);
                }
                $comms = new comms();
                $RXData = $comms->unPack($buf, $rxsocket, $remote_ip, $remote_port, $authok);
                if ($RXData == "AuthOK") {
                    socket_close($ary[1]);
                    if (socket_write($ary[0], $remote_ip, strlen($remote_ip)) === false) {
                        echo "socket_write() failed. Reason: " . socket_strerror(socket_last_error($ary[0]));
                    }
                    socket_close($ary[0]);
                    e('Unit authenticated ok ');
                }
                die;
                //kill child process
            }
        }
    }
} while (true);
socket_close($rxsocket);