Bug #1854: fsockopen does not work when used multiple times

From: Date: Fri, 23 Jul 1999 22:27:40 +0000
Subject: Bug #1854: fsockopen does not work when used multiple times
Groups: php.dev 
Request: Send a blank email to php-dev+get-9069@lists.php.net to get a copy of this message
From: taoliang@cdr.stanford.edu Operating system: Linux PHP version: 3.0.8 PHP Bug Type: Other Bug description: fsockopen does not work when used multiple times The following function will work only once when called multiple times. My guess is that the file pointer have to be reset (feof($fp) shows true after the first time the function is called). function get_data() { $fp = fsockopen("www.php.net", 80, &$errno, &$errstr); if (!$fp) { echo "$errstr ($errno)<br>\n"; $err = 1; } else { fputs($fp,"GET /quote.asp?Symbol=$ticker HTTP/1.0\n\n"); echo "$fp, ", feof($fp), "\n"; while(!feof($fp)) { $resp .= fgetss($fp,4096); } fclose($fp); } echo $resp; } Let's say I do the following: for ($i=0;$i<10;$i++) { echo "start...\n"; get_data(); } It will return valid output for the first time, and the rest will just be blank.

« previous php.dev (#9069) next »