|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63793 Provide direct access to socket errors without php_sockets
Submitted: 2012-12-18 00:19 UTC Modified: 2021-07-27 13:45 UTC
Avg. Score:4.3 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:6 (85.7%)
Same OS:6 (85.7%)
From: chrisw at networkm dot co dot uk Assigned: cmb (profile)
Status: Duplicate Package: Streams related
PHP Version: Irrelevant OS: Any
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.
Block user comment
Status: Assign to:
Bug Type:
From: chrisw at networkm dot co dot uk
New email:
PHP Version: OS:


 [2012-12-18 00:19 UTC] chrisw at networkm dot co dot uk
Would it be possible to provide access to socket error codes/messages without the 
need to import the underlying socket into php_sockets?

It is often desirable to access the error information when a socket operation 
fails, and currently this is only possible via socket_import_stream, and 
subsequent calls to socket_last_error/socket_strerror. This is only possible if 
php_sockets is available to the PHP installation, which is frequently not the 

Test script:

  $socket = stream_socket_client('tcp://');

  if (fwrite($socket, 'some data') === false) {
    $errCode = stream_socket_error($socket);
    echo 'Sending data failed: Socket error #'.$errCode;

Expected result:
Sending data failed: Socket error #<error code>

Actual result:
Fatal error - stream_socket_error or an equivalent function does not exist


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-27 13:45 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-07-27 13:45 UTC]
This is a duplicate of bug #34380.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 11:01:30 2024 UTC