|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62960 non block stream does not work with ssl
Submitted: 2012-08-28 19:07 UTC Modified: 2022-08-05 21:08 UTC
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jim dot javathunderbird at gmail dot com Assigned: bukka (profile)
Status: Not a bug Package: Streams related
PHP Version: 5.4.6 OS: CentOS 64 bit
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:
10 + 42 = ?
Subscribe to this entry?

 [2012-08-28 19:07 UTC] jim dot javathunderbird at gmail dot com
When using stream_socket_server with non blocking stream, there seems to have no way to write buffer to client. When the stream is in blocking mode, things start working again.

Test script:
$protocol = "ssl";
$ip = "";
$port = 8000;
$context = stream_context_create();
$certificate = __DIR__."/certificate_concat.pem";
stream_context_set_option($context, 'ssl', 'local_cert', $certificate);
stream_context_set_option($context, 'ssl', 'verify_peer', false);
$server = stream_socket_server("$protocol://$ip:$port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
stream_set_blocking($server, 0); //when set to non blocking, ssl will not work, if set to blocking, things start working again
  $client = stream_socket_accept($server);
  print "accepted " . stream_socket_get_name( $client, true) . "\n";
  if( $client )
    fwrite($client, "hello");
  } else {
    print "error.\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-03 10:24 UTC] heruan at aldu dot net
No one has ever given a feedback to this bug. It still affects PHP 5.5.9, any chance to get this fixed in 5.6?
 [2014-04-03 10:58 UTC] heruan at aldu dot net
Note that *writing* to the encrypted stream seems working, it's *reading* that won't work and it is reported on #65137.
 [2022-08-05 21:08 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: bukka
 [2022-08-05 21:08 UTC]
This is unlikely an issue in PHP as this has been working fine for years. Maybe there was an issue that got fixed but think it's more likely application usage issue - for example I don't see any use of stream_select in the example which is often needed for non blocking read. Also note that stream_socket_accept will return blocking socket on Linux so that might have been confusing as well. Anyway non blocking read with TLS is definitely working if used correctly. If you still experience, please open a new issue in GitHub with more details what exactly doesn't work for you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 23:01:32 2024 UTC