<?php
function doLocalForwardMSG($msg,$ip,$port)
{
    $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);

    $len = strlen($msg);

    socket_sendto($sock, $msg, $len, 0, $ip, $port);
    socket_close($sock);
}

$message="";

//read all from stdin
$fd = fopen("php://stdin", "r");
while (!feof($fd)) $message .= fread($fd, 1024);
//do forward to collector
doLocalForwardMSG($message,"127.0.0.1",39009);
fclose($fd);
?>