1

This is my code:

<?php
function stribet2($inputstr, $deliLeft, $deliRight){
$posLeft = stripos($inputstr, $deliLeft) + strlen($deliLeft);
$posRight = stripos($inputstr, $deliRight, $posLeft);
return substr($inputstr, $posLeft, $posRight - $posLeft);
}
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);;
$result = socket_bind($socket, "localhost", 888);
$result = socket_listen($socket, 3);
socket_set_option($socket,SOL_SOCKET, SO_RCVTIMEO, array("sec"=>2, "usec"=>0));
$socket2 = socket_create(AF_INET, SOCK_STREAM, 0);
$result2 = socket_bind($socket2, "127.0.0.1", 1337);
$result2 = socket_listen($socket2, 3);
socket_set_option($socket2,SOL_SOCKET, SO_RCVTIMEO, array("sec"=>2, "usec"=>0));

I get the error "Fatal error: Call to undefined function socket_create() in (b)(directory)(/b).

John Conde
  • 217,595
  • 99
  • 455
  • 496
Protruth
  • 11
  • 1
  • 2

1 Answers1

3

You need to enable sockets in your php.ini file

If you are on windows: open your php.ini file and around the line 650 region, find this:

;extension=php_sockets.dll 

and change it to

extension=php_sockets.dll

(remove the semicolon in the beginning)

Krimson
  • 7,386
  • 11
  • 60
  • 97