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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC