RE: [PHP-DEV] fsockeropen() & file() problem.

From: Date: Thu, 29 Jun 2000 12:01:14 +0000
Subject: RE: [PHP-DEV] fsockeropen() & file() problem.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-22749@lists.php.net to get a copy of this message
Hi, concerning about the fsockopen timeout parameter I have also encountered some limitations... I think that the time out reffers only to the open of the connection, but there are some other timeouts that I couln?d find how to handle them. For example: I make a conection to foo.com, port 110. The server is up and I enter the function... but the I whant to send user & pass and the server does not answer... The gets function will be waiting till it receives something... In c++ you can handle that timeouts but in php I couldn't find how. I have tested it around with a simple server which echoes everiting I send and if I put a sleep (30) the gets will wait for 30 secs.. & so on... If anyone needs the simple server in perl to test it out please drop me a line... -----Mensaje original----- De: php_list@citiz.net [mailto:php_list@citiz.net] Enviado el: Lunes, 26 de Junio de 2000 06:33 a.m. Para: php-dev@lists.php.net CC: php4beta@lists.php.net Asunto: [PHP-DEV] fsockeropen() & file() problem. Hello php-dev, I have this code todo something: while(true){ print "start download\n"; if ($Arr_Stock = file("http://stock.net/allstockdata.asp?page=1")){ print "download done\n" /* some code to do write array $Arr_Stock */ }else{ print "download fail"; sleep(5); } } This code it work good most time, but when remote server "stock.net" down This code it print "start download", and it hold run, not print "download fail" not return anything, I must kill this pid, and restart it. So I use follow code instead it: while(true){ $fp = fsockopen("stock.net", 80, &$errno, &$errstr, 5); /* I think "5" is time out when remote server down. */ if(!$fp) { print "download fail"; sleep(5); } else { set_socket_blocking($fp, false); fputs($fp,"GET /allstockdata.asp?page=1\n\n"); while(!feof($fp)) { $Str_StockMsg .= fgets($fp,1024); } fclose($fp); $Arr_Stock = explode("\n",$Str_StockMsg); /* some code to do write array $Arr_Stock */ } } It work fine than first code, but still die sometimes, I find function set_socket_timeout() in php3, I want try it, but in php4 this function not find. Any have good idea ?? Please help me! Sorry for my english so poor. -- Best regards, php -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.dev (#22749) next »