|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49166 called to undefined function socket_create
Submitted: 2009-08-05 04:14 UTC Modified: 2009-08-05 23:09 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: s dot daudell at boldwebservices dot com Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 5.3.0 OS: Windows XP Pro
Private report: No CVE-ID: None
 [2009-08-05 04:14 UTC] s dot daudell at boldwebservices dot com
I just installed a newer version of WAMP, with php 5.3.0 and enabled sockets.

This script has worked fine on older versions of php, but now is coming up with an 'called to undefined function socket_create();' error

Reproduce code:
//-- Set some variables
$host			  = "";
$port			  = 9001;

//-- Create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");

//-- Bind socket to port
socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
echo "Binded to server address: ".$host."\r\n"."On port: ".$port."\r\n\r\n";

//-- Start listening for connections
socket_listen($socket, 3) or die("Could not set up socket listener\n");
echo "Waiting for connections...\r\n";

Expected result:
It should start listening for raw text to come in on that data.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-05 07:36 UTC]
Wild guess: sockets extension isn't loaded? Check your phpinfo() output.
 [2009-08-05 08:05 UTC] s dot daudell at boldwebservices dot com
As i mentioned, sockets are enabled, the extension shows up as loaded, in the WAMP interface, in phpinfo(), and in php.ini

However when the function is called, it results in a fatal error. This same script worked fine in 5.2.6

I was installing my software on a new machine with the newer version of PHP, following my same setup procedures that worked before, and now it doesnt work.
 [2009-08-05 14:32 UTC]
It's quite impossible for this function not exist if the sockets extensions is really loaded. Please check again. And this time with this script:


$foo = socket_create(AF_INET, SOCK_STREAM, 0);

 [2009-08-05 15:29 UTC] s dot daudell at boldwebservices dot com
i commented out all of my other code and inserted only the script you provided. it still results in a fatal error. I check the phpinfo() output once again, still says sockets support enabled.
 [2009-08-05 21:47 UTC]
It's not really loaded if the function doesn't exist, try this:

<?php var_dump(extension_loaded("sockets")); ?>

 [2009-08-05 22:48 UTC] s dot daudell at boldwebservices dot com
ok here is something i found. when i run this script in a web browser, it validates to bool(true), which explains why it is loaded in phpinfo()

yet when i run this script in the command prompt, it returns bool(false)

what would be causing the cmd to not access that extension?
 [2009-08-05 22:59 UTC]
You probably have a different php.ini being loaded for the CLI.

Regardless this isn't a bug and a support issue.
 [2009-08-05 23:09 UTC] s dot daudell at boldwebservices dot com
it was indeed using a different php.ini

got it all working now. thanks
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 04:03:40 2023 UTC