So I have tested socket with this piece of code, it is working fine (SOCK_STREAM)
<?php
set_time_limit(0);
$sock = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket \n");
$result = socket_bind($sock, $host, $port) or die("Could not bind to socket \n");
$result = socket_listen($sock, 3) or die("Dould not set up socket listener \n");
echo "Listening for connection \n";
// LOOP FOREVER
do {
$accept = socket_accept($sock) or die ("Could not accept incoming connection \n");
$msg = socket_read($accept, 100000) or die("Could not read input \n");
echo "Client says: " . $msg . "\n\n\n";
} while(true);
socket_close($accept, $sock);
But the problem is when i try to change the socket_create() to SOCK_RAW
$sock = socket_create(AF_INET, SOCK_RAW, 1) or die("Could not create socket \n");
or
$sock = socket_create(AF_INET, SOCK_RAW, 0) or die("Could not create socket \n");
or
$sock = socket_create(AF_INET, SOCK_RAW, getprotobyname('icmp')) or die("Could not create socket \n");
I have the following error:
PHP Warning: socket_listen(): unable to listen on socket [10045]: The attempted operation is not supported for the type of object referenced in C:\xampp\htdocs\wialon php script\server.php on line 10
Warning: socket_listen(): unable to listen on socket [10045]: The attempted operation is not supported for the type of object referenced in C:\xampp\htdocs\wialon php script\server.php on line 10
Dould not set up socket listener
Please help. Thank you in advance.