timeout parameter of fsockopen function not working?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rahesh
Forum Newbie
Posts: 3
Joined: Thu May 14, 2009 7:36 am

timeout parameter of fsockopen function not working?

Post by rahesh »

Hi

Here is my code :

<?php
$status=0;
if(isset($_GET['host']) && isset($_GET['port'])){
try{
$fp = @fsockopen ($_GET['host'], $_GET['port'], $errno, $errstr, 5);
if ($fp) {
$status=1;
fclose($fp);
}
}
catch(Exception $ex){

}
}
echo $status;
?>

Here the timeout parameter is not working.

Anybody please help me in this.

Regards
Rahesh
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: timeout parameter of fsockopen function not working?

Post by AbraCadaver »

How do you know it's not working???
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
rahesh
Forum Newbie
Posts: 3
Joined: Thu May 14, 2009 7:36 am

Re: timeout parameter of fsockopen function not working?

Post by rahesh »

its taking more than 5 seconds to get response..
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: timeout parameter of fsockopen function not working?

Post by Apollo »

Try this first:

Code: Select all

ini_set('default_socket_timeout',5);
Post Reply