Ajay_kumar
Ajay_kumar

Reputation: 57

Socket programming error

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

Upvotes: 2

Views: 533

Answers (3)

chh
chh

Reputation: 593

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.

Upvotes: 0

codaddict
codaddict

Reputation: 455440

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

Upvotes: 1

Artefacto
Artefacto

Reputation: 97845

The sockets extension is not activated.

You should load php_sockets.dll in php.ini.

Upvotes: 1

Related Questions