Hey guys, i found this piece of code that is suppose to read a port on my server and write to a .txt file the gps data it get gets.
am receiving nothing, am not not sure what the problem is, also am new to gps and php socket programming... pls help out, thx.
<?php
error_reporting(E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
// Server IP address
$address = "xxx.xxx.xxx.xx";
// Port to listen
$port = 443;
$mysock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($mysock,$address, $port) or die('Could not bind to address');
//socket_listen($mysock, 5);
socket_listen($mysock);
$client = socket_accept($mysock);
// read 1024 bytes from client
$input = socket_read($client, 1024);
// write received gprs data to the file
writeToFile('gprs.txt', $input);
socket_close($client);
socket_close($mysock);
?>
<?php
function writeToFile($strFilename, $strText) {
if($fp = @fopen($strFilename,"w")) {
$contents = fwrite($fp, $strText);
fclose($fp);
return true;
} else {
return false;
}
}
?>