php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41512 ssl: socket_set_blocking not working
Submitted: 2007-05-27 12:55 UTC Modified: 2007-05-27 17:06 UTC
From: darkbytes at linuxwaves dot com Assigned:
Status: Closed Package: Streams related
PHP Version: 5.2.2 OS: Linux
Private report: No CVE-ID: None
 [2007-05-27 12:55 UTC] darkbytes at linuxwaves dot com
Description:
------------
socket_set_blocking() is not working on a ssl-connection.
the reproduce code shows a connection without and with ssl, and 
loops for each to 10 when socket_set_blocking is working. 

plain sourcepacket from php.net, no patches:
./configure --enable-sockets --with-openssl

Reproduce code:
---------------
 <?php
        echo "connecting without ssl\n";
        $sock = fsockopen("euserv.de", 80,$errno, $errstr, 30);
        if($sock) echo "connected;\n";
        socket_set_blocking($sock, 0);  $count=0;
        while (!feof($sock)) {        
            echo "loop: ".$count."\n";
            fgets($sock, 4096);
            if($count==10) break;
            $count++;
        }
        fclose($sock);
        unset($sock);
        if($count==10) echo "stream_set_blocking(\$sock, 0); seems to work without ssl!\n"; else echo "it is not working :(\n";
        echo "connecting with ssl\n";
        $sock = fsockopen("ssl://euserv.de", 443,$errno, $errstr, 30);
        stream_set_blocking($sock, 0);  $count=0;
        while (!feof($sock)) {        
            echo "loop: ".$count."\n";
            fgets($sock, 4096);
            if($count==10) break;
            $count++;
        }
        fclose($sock);
        unset($sock);
        if($count==10) echo "stream_set_blocking(\$sock, 0); seems to work with ssl!\n"; else echo "it is not working :(\n";
?>
  

Expected result:
----------------
it should loop from 0 to 10 two times - with and without ssl.

Actual result:
--------------
for me and a friend it outputs:
[root@raw www]# php block.php
connecting without ssl
connected;
loop: 0
loop: 1
...
loop: 10
stream_set_blocking($sock, 0); seems to work without ssl!
connecting with ssl
loop: 0
---- here it hangs - socket seems to wait for input.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-27 17:06 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 13:01:32 2024 UTC