|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7862 On a network connection fgetc hangs when NULL bytes get involved
Submitted: 2000-11-17 05:41 UTC Modified: 2000-12-30 19:56 UTC
From: burwitz at mails-media dot de Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.3pl1 OS: SuSE Linux 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
25 + 25 = ?
Subscribe to this entry?

 [2000-11-17 05:41 UTC] burwitz at mails-media dot de
I have the following problem:

$fp	=fsockopen($server, 8611, &$errno, &$errstr);
while(feof($fp)!=true) {
	echo "X";		# for debuging
	flush();		# for debuging
	fflush($fp);		# for debuging

	$str.=fgetc($fp);	# or fgets($fp,2); or fread($fp,1);

	echo "Y";		# for debuging
	flush();		# for debuging
	fflush($fp);		# for debuging
} # while

Would produce "XYXYXYXYXYXYX"

When the received data looks like "%00%0A%00%00%00%00%00%00"
in HEX. That means at the last character which is a NULL-byte
the fgetc or fgets or fread would hang!

BUT fread($fp,8); works! But I need it for variable length as

Thanks for the help


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-21 07:27 UTC]
I don't see a bug here. At least on my system, it reads 8
characters, and then waits for the next one - since eof is
not signalled until the connection is closed. So it's
completely OK. Please check that it indeed sends 8
characters and reads only 6 and then hangs - I was unable to
reproduce this on my system.
 [2000-12-30 19:56 UTC]
No feedback.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jun 09 07:03:39 2023 UTC