I've followed a tutorial to create a socket server in PHP however I am getting the following error:
Heres my code:Parse error: syntax error, unexpected T_NS_SEPARATOR, expecting T_STRING in /Applications/XAMPP/xamppfiles/htdocs/script.php on line 9
Any help would be greatly appreciated!PHP Code:
<?
$host = "127.0.0.1";
$port = 6932;
set_time_limit(0);
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
$result = socket_listen($socket, 3) or die("Could not set up socket listener\n");
$spawn = socket_accept($socket) or die("Could not accept incoming connection\n");
$input = socket_read($spawn, 1024) or die("Could not read input\n");
$input = trim($input);
$output = strrev($input) . "\n";
socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n");
socket_close($spawn);
socket_close($socket);
?>