Hi
We are doing a socket that send a variable to our credit card processor server. We need to display an error and delete some entry in the db if we don't receive the final "OK" or if the script hang. What we are looking for are timeout on each fgets to make sure that if we don't receive anything, the script won't hang. How could this be done? thanks
Here our current code:
$tmp = fgets($socket, 1024);
if ($tmp = 'HELLO'){
if (fputs($socket, "HELLO\n")){
$tmp2 = fgets($socket, 1024);
if ($tmp2 = 'READY'){
if (fputs($socket, "ChargeID:$ChargeID\n")){
$tmp3 = fgets($socket, 1024);
if ($tmp3 = 'OK'){
fclose($socket);
Header("Location: checkstatus.php");
}
else {
echo 'error';
fclose($socket);
exit;
}
}
}
}