Hi
I have PHP script that uses fsockopen for sending and receiving data from a server (VB program acting as server on a PC), I can send and receive data, I want that my PHP script sends a message when the connection with the server can't be establish. This is my PHP code:
When the server is down I have to receive the message "Cannot Connect" from PHP, I just receive the PHP timeout message at 30 seconds:
Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:21
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\ on line 25
Any Ideas
Thanks!!
I have PHP script that uses fsockopen for sending and receiving data from a server (VB program acting as server on a PC), I can send and receive data, I want that my PHP script sends a message when the connection with the server can't be establish. This is my PHP code:
Code:
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<style type="text/css">
<!--
.style1 {
color: #0000FF;
font-weight: bold;
}
-->
</style>
<label></label>
<form id="form1" name="form1" method="post" action="">
<p><?php
$server="localhost";
$port=21;
$data="Hi";
//Connection
$conec= fsockopen($server,$port);
//If not connect
if(!$conec) {
echo ("Cannot Connect");
}
else {
fputs($conec,"$data");
$var=fgets($conec,256);
fclose($conec);
}
echo "<tr>
<td> $var </td>
</tr>";
?>
</table>
</p>
<p>
<input name="Submit" type="submit" onclick="MM_goToURL('parent','menucssn.php');return document.MM_returnValue" value="Home" />
</p>
</form>
When the server is down I have to receive the message "Cannot Connect" from PHP, I just receive the PHP timeout message at 30 seconds:
Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:21
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\ on line 25
Any Ideas
Thanks!!