php.net |  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
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: burwitz at mails-media dot de
New email:
PHP Version: OS:

 

 [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
well!

Thanks for the help


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-21 07:27 UTC] stas@php.net
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] sniper@php.net
No feedback.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC