2

When I am running my program of socket I am getting an error:

Fatal error: Call to undefined function socket_create() in C:\wamp\www\sockert\sockert.php on line 11

What about that error?


Code:

// set some variables
$host = "192.168.1.99";
$port = 1234;
// don't timeout!
set_time_limit(0);
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");

I am using php5.3.0

2
  • Please post the code that causes the error. Also, what version of PHP are you using? Commented Sep 5, 2010 at 2:54
  • // set some variables $host = "192.168.1.99"; $port = 1234; // don't timeout! set_time_limit(0); // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); ... ... I am using php5.3.0 Commented Sep 5, 2010 at 3:02

3 Answers 3

1

The sockets extension is not activated.

You should load php_sockets.dll in php.ini.

Sign up to request clarification or add additional context in comments.

Comments

1

In the file php.ini file, find the line with php_sockets.dll and remove the leading semi colon (;)

2 Comments

I did it. I remove the ; from my extension and just download and place php_sockets.dll in dll directory where all supporting dll are kept. but still getting this error.
Now this is running i was changed in php instead of apache. this is enabled now.thanks
0

The functions staring with socket_ are not activated by default in PHP. But there exists a better alternative anyways: the stream extension offers support for sockets too, and this is available regardless of your PHP and platform, and is also much more easy to use.

I've written a blog post explaining Stream Sockets here: http://www.christophh.net/2012/07/24/php-socket-programming/

I hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.