Could any one tell me how to enable SOCKET support in PHP ?
5 Answers
This answer assumes you do have a php_sockets.dll
extension file accessible (in your PHP installation extension directory or where required);
If you're using windows, just uncomment the following line in your php.ini
file:
;extension=php_sockets.dll
If you are missing the php_sockets.dll
, you can download it from php.net.

- 6,899
- 7
- 44
- 59

- 265,109
- 74
- 539
- 565
-
2I have a linux godadday machine running a website. How do I enable socket programming there? – user1051505 Jan 11 '13 at 12:56
-
2@user1051505 You might find [this discussion](http://support.godaddy.com/groups/web-hosting/forum/topic/php-sockets/?pc_split_value=2) in the GoDaddy forums to be helpful. – Sampson Jan 11 '13 at 15:46
-
I'm using XAMPP and I was getting `"Call to undefined function socket_create()..."` error. Although I have the `php_sockets.dll` file, `extension=php_sockets.dll` was not added to the `php.ini`. I had to add it manually. Now, it's working. – akinuri Apr 09 '18 at 06:53
-
3in xampp server , its ;extension=sockets. this helped. – adeel ahmad Jun 07 '20 at 07:02
The PHP Docker images come with 3 helper script commands that make installing and configuring extensions easier:
docker-php-ext-configure
: This command allows you to provide the custom arguments for an extension.docker-php-ext-install
: Use this command to install new extensions in your container.docker-php-ext-enable
: This command can be used to enable PHP extensions.
Run
docker-php-ext-install sockets

- 10,951
- 6
- 52
- 65
-
3
-
1This showing a lot of errors. _/usr/src/php/ext/sockets/sendrecvmsg.c:128:19: error: invalid application of 'sizeof'_, _/usr/src/php/ext/sockets/sendrecvmsg.c:129:36: error: 'SCM_CREDS' undeclared_, And in the end: _make: *** [Makefile:213: sendrecvmsg.lo] Error 1_ (PHP 8.1 x64) – vee Jan 22 '22 at 13:59
here are noobs instructions
go to your php installation directory in windows it can be something like this c:\xampp\php
the go to ext directory in php\ext\
check if your have php_sockets.dll in that directory
after that open php.ini file which will be in your php folder
next search for
;extension=php_sockets.dll
if you find it then remove ;
from it
if you not find it then search for extension=
and then below some extension add extension=php_sockets.dll
- and finally restart your apache service.

- 4,353
- 3
- 48
- 51
-
4in xampp latest version you will found ;extension=sockets not this ;extension=php_sockets.dll so you need to remove ; from ;extension=sockets and restart your apache. – Atul Baldaniya Jun 08 '21 at 06:04
For those of you that having this problem when installing RabbitMQ php library
Problem 1
- Installation request for php-amqplib/php-amqplib ^2.11 -> satisfiable by php- amqplib/php-amqplib[v2.11.0].
- php-amqplib/php-amqplib v2.11.0 requires ext-sockets * -> the requested PHP extension sockets is missing from your system.
Solution
change ;extension=sockets
to extension=sockets
over php.init
Notes:
Not sockets.dll, only sockets

- 1,058
- 3
- 13
- 21

- 517
- 5
- 11
-
1well I didn't solved my similar problem with this answer, but this answer is true and I solved it and then saw this answer. silly me :) – mohammad fallah.rasoulnejad Mar 21 '20 at 14:02
-
-
Note that it might be in a separate `.ini` file. You can list all loaded files with `php --ini`. In my case I had it in `20-sockets.ini`. – The Unknown Dev Jul 02 '21 at 14:25
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.
From the extension's documentation.

- 73,842
- 19
- 118
- 155