Kavishka Madhushan
Kavishka Madhushan

Reputation: 156

PHP Fatal error: Uncaught Error: Call to undefined function socket_create() in XAMPP v3.3.0 in windows

<?php
    $host = "localhost";
    $port = "1234";
    set_time_limit(0); // no time out

    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("could not create socket\n");
    $socket_binded = socket_bind($socket, $host, $port) or die("Could not bind socket\n");
    $socket_listen = socket_listen($socket, SOMAXCONN) or die("c;old not setup socket listen\n");
    $socket_accept = socket_accept($socket) or die("accetp fail\n");
    $input = socket_read($socket_accept, 1024) or die("Could not read inputs");
    $input = trim($input);
    echo $input;
    socket_write($socket, $input, strlen($input)) or die("Could not write");
    socket_close($socket_accept);
    socket_close($socket);

?>

Hi, I have some problem with php sockets. this is my "server.php" code and I tried to run it using "php server.php". But it gives bellow error. enter image description here

I referred some similar problems that are in stack overflow. I uncomment "php.ini" socket extension(";extension=sockets") in XAMPP v.3.3.0 as "extension=sockets" and restarted. but still it not work and I tried to add "extension=php_sockets.dll" manually. But still not work.

enter image description here

Also I think extension directory is ok in my php.ini file.

enter image description here

also my sockets.dill file have that location.

enter image description here

Also I install again XAMPP. But still not work it.

Can someone help me to solve this issue?

Upvotes: 0

Views: 1240

Answers (1)

Kavishka Madhushan
Kavishka Madhushan

Reputation: 156

Sorry. finally found it. Instead of xampp PHP library, I had another PHP library in my program files in C drive when I changed its extensions sockets. Now every thing ok.

Upvotes: 1

Related Questions