I got a big report with a bunch of php specs and such just like you said I would. I am just curious why I can not run my script from a web page and be able to sit there and watch the values change. I can not see anything until I shut down my client completely and then the output prints. I even tried commenting out the 2 close statements that I have at the end of my code and it still did not change anything. Is my code wrong? Here is another look at it...maybe something will jump out at you that I am not seeing:
#!/usr/bin/php5 -q
<?php
function giveMeAnArray($delimiter, $string) {
return explode($delimiter, $string);
}
$read_write = "read";
if ($read_write == "read") {
//Initialize the socket
set_time_limit(0);
$address = '127.0.0.1';
$port = 10119;
$counter = 0;
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
echo "socket_create() failed. Reason: " . socket_strerror($sock) . "<BR>";
}
if (($ret = socket_bind($sock, $address, $port)) < 0) {
echo "socket_bind() failed. Reason: " . socket_strerror($ret) . "<BR>";
}
//Start listening on the socket
if (($ret = socket_listen($sock, 5)) < 0) {
echo "socket_listen() failed. Reason: " . socket_strerror($ret) . "<BR>";
}
//do {
//Accept an incoming connection
if(($client = socket_accept($sock)) < 0) {
echo "socket_accept() failed. Reason: " . socket_strerror($ret) . "<BR>";
break;
}
do {
//Read whatever was just sent, 1024 bytes' worth. Make this however long you need.
if( false == ($global_string = socket_read($client, 2048))) {
echo "socket_read() failed. Reason: " . socket_strerror($ret) . "<BR>";
break ;
};
if (!$global_string = trim($global_string)) {
continue;
}
else {
print ("Serving Client!<BR>");
}
//Strip whitespace
$global_string = ereg_replace("[ \t\n\r]", "", $global_string).chr(0);
$delim = ',';
$array = giveMeAnArray($delim, $global_string);
$id = $array[0];
$Width = $array[1];
$footagecount = $array[2];
$Length = $array[3];
$counter++;
} while (true);
//Close the connection; Don't leave things like this open...!!
// socket_close($client);
//} while (true);
//Close the socket itself
socket_close($sock);
print("Coil ID number: $id<BR>");
print("Coil Width: $Width<BR>");
print("Footage Count: $footagecount<BR>");
print("Coil Length: $Length<BR>");
header( "Location:
http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'] );
} //ends if ("read")