I have a socket server in php server.php
$master = WebSocket("localhost",800);
$sockets = array($master);
$users = array();
$debug = false;
function WebSocket($address,$port)
{
$master=socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("socket_create() failed");
socket_set_option($master, SOL_SOCKET, SO_REUSEADDR, 1) or die("socket_option() failed");
socket_bind($master, $address, $port) or die("socket_bind() failed");
socket_listen($master,20) or die("socket_listen() failed");
echo "Server Started : ".date('Y-m-d H:i:s')."\n";
echo "Master socket : ".$master."\n";
echo "Listening on : ".$address." port ".$port."\n\n";
return $master;
}
On my command line, I did
sudo chmod 777 /socket/websocket/server.php
then
php -q /socket/server.php trying to bring it up.
then there's an error,
Warning: socket_bind(): unable to bind address [13]: Permission denied in /socket/websocket/server.php on line 60
line 60 is
socket_bind($master, $address, $port) or die("socket_bind() failed");
$master=id+4
$address=localhost
$port=800
I mean I already chmoded that file into 777, why still unable to bindaddress for the socket server file?
If I changed port address to 12345. then new error would say
Warning: socket_bind(): unable to bind address [48]: Address already in use in /socket/websocket/server.php on line 67