php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1567 socket problem with fsockopen
Submitted: 1999-06-18 18:54 UTC Modified: 1999-06-20 06:49 UTC
From: smweb at ihost dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.8 OS: SuSE Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: smweb at ihost dot de
New email:
PHP Version: OS:

 

 [1999-06-18 18:54 UTC] smweb at ihost dot de
I have a while loop which opens and closes a socket connection about 100 times:

while (...) {
	$fp = fsockopen("myserver.com", 8800);
	fputs($fp, $strRequest);

	while ($buffer = fgets($fp, 4096)) {
		chop($buffer);
		$strResultr = $strResult . substr($buffer, 8) . "<br>";
	}
	fclose($fp);
}

The following happens:
- if I run it like it is above the socket is only opened the first time the while loop is passed through. In all of the following loops the socket is not opened anymore.
- If I remove the fclose-command, it works. BUT: This way I sometimes get this warning message:

Warning: Unable to find file identifier 0 in /www/ihost.de/htdocs/lexidom/check.html on line 49
Warning: Unable to find file identifier 0 in /www/ihost.de/htdocs/lexidom/check.html on line 54

Line 49 contains:
fputs($fp, $strRequest);

Line 54 contains:
while ($buffer = fgets($fp, 4096)) {

Don't I have to fclose the socket connection? Why doesn't it work when I close it? Why doesn't it work everytime when I don't close it?

I'd be very thankful for an answer.
- Steffen

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-20 06:49 UTC] sas at cvs dot php dot net
These kind of problems should be fixed in the latest CVS. You might want to give it a try (see http://cvs.php.net )
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 13:00:02 2026 UTC