|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28953 feof no longer detects SSL connections closed by the server
Submitted: 2004-06-29 05:41 UTC Modified: 2004-06-29 20:59 UTC
From: mlemos at acm dot org Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.3.7 OS: *
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:
33 + 35 = ?
Subscribe to this entry?

 [2004-06-29 05:41 UTC] mlemos at acm dot org
It seems that there were changes introduced after PHP 4.3.6, the feof function is no longer returning true when the server closes the SSL socket connection after transmiting all the contents.

This seems to make it impossible to determine if there was a real network error or the server closed the connection normally breaking the compatibility of scripts that rely on feof to determine the end of connection condition.

This seems to be a revival of bug 25939. It happens under PHp 4.3.2, 4.3.3, 4.3.4 and 4.3.7 . I does not happen under PHP 5.0.0RC3 .

Although I could only reproduce it for SSL connections. It may be affecting normal TCP connections but I could not yet produce a test script to demonstrate it consistently.

Reproduce code:
        $socket=fsockopen("ssl://", 443, $error);
                echo "socket opening error\n";
        echo "connection opened\n";
        if(!fputs($socket, "GET / HTTP/1.1\r\nHost:\r\n\r\n"))
                echo "socket writing error\n";
                $data=fread($socket, 1000);
                        echo "socket reading error\n";
                echo "read ",strlen($data)," bytes\n";
        echo "reached the end of data\n";

Expected result:
connection opened
read 574 bytes
reached the end of data

Actual result:
connection opened
read 574 bytes
socket reading error


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-29 17:41 UTC]
Please try using this CVS snapshot:
For Windows:

Works fine with latest CVS, the provided script returns the 
following (correct) output: 
connection opened 
read 238 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 1000 bytes 
read 777 bytes 
reached the end of data 
 [2004-06-29 19:02 UTC]
If you're reading data from a M$ server you will encounter this problem; there is not really anything we can do about it, since masking the error will mask legitimate errors.

See Bug #23220
 [2004-06-29 19:56 UTC] mlemos at acm dot org
I am not sure if this was the problem, but I have updated the OpenSSL installation (openssl-0.9.7b-133 now) with SuSE Linux YAST Online Update program that applies patches that fix bugs and security vulnerabilities and today I am no longer able to reproduce the problem.
 [2004-06-29 20:59 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Since the user reports that the problem was resolved 
through an upgrade of the openssl library. I can only 
assume the problem was with the library and not PHP. 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 26 02:05:45 2022 UTC