Código PHP:
<?php
set_time_limit(11*60);
$link = mysql_connect('localhost', 'xxxxx', 'xxxxx');
if (!$link) {
die('No se Conecto : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('xxxxx', $link);
if (!$db_selected) {
die ('no se selecciono la base de datos xxxxxx : ' . mysql_error());
}
/**/
define('E_STRICT', 2048);
error_reporting(E_ALL | E_STRICT);
ob_implicit_flush();
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, '10.0.0.66', 200);
$from = "200.95.162.244";
$port = 36363;
$i=0;
while($i<=12000)
{
echo "Received ";
for ($j = 0; $j < 57; $j++) {
print $buf[$j] . "\n";
socket_recvfrom($socket, $buf, 57, 0, $from, $port);
}
//$buf from remote address $from and remote port $port" . PHP_EOL.'<br>';
//mysql_query('commit');
$i++;
mysql_query("insert into coordenadas (datos_trama,ip,puerto,campo_binary) values ('$buf','$from','$port','$buf')",$link);
}
mysql_close($link);
echo "fin";
socket_shutdown($socket);
socket_close($socket);
?>