php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43417 socket_read returns FALSE not "" on "no more data"
Submitted: 2007-11-26 20:06 UTC Modified: 2007-11-27 13:02 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: miniman dot k3o at gmail dot com Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 5.2.5 OS: Linux Slackware
Private report: No CVE-ID: None
 [2007-11-26 20:06 UTC] miniman dot k3o at gmail dot com
Description:
------------
cyte from php.net/socket_read :

Return Values

    Note: socket_read() returns a zero length string ("") when there is no more data to read.

//

Ive downloaded today PHP 5.2.5 sources from php.net site. Compiled it. Start my server and saw that it: returns FALSE on 'NO MORE DATA TO READ'

//

I think it is a bug;

Reproduce code:
---------------
php-5.2.5/ext/sockets
isn't it a patch ?

--- sockets.c   2007-09-26 12:55:07.000000000 +0200
+++ sockets.c.fixed     2007-11-26 19:51:23.000000000 +0100
@@ -891,6 +891,10 @@
                ) {
                        php_sock->error = errno;
                        SOCKETS_G(last_error) = errno;
+                       /*minicode starts: return empty string bugfix*/
+                       efree(tmpbuf);
+                       RETURN_STRINGL('\0',0,0);
+                       /*minicode ends*/
                } else {
                        PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
                }



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-26 20:16 UTC] miniman dot k3o at gmail dot com
>Start my server and saw that it: returns FALSE on 'NO MORE DATA TO
READ'

i meant:

Started my server and saw that socket_read: returns FALSE on 'NO MORE DATA TO READ'
 [2007-11-27 13:02 UTC] jani@php.net
"socket_read() returns the data as a string on success, or FALSE on error (including if the remote host has closed the connection). The error code can be retrieved with socket_last_error()."

What happens is that the remote closed the connection..see also bug #28141
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 25 05:03:35 2022 UTC