PHP Socket Not Listening -


include 'config.php'; set_time_limit(0); //sending message $msgokay = "okay"; $msg1 = "1"; $msg2 = "2"; $msg3 = "3"; $msg4 = "4"; $msg5 = "5"; $msg6 = "6";  echo "starting listening master. \n";  $sock = socket_create(af_inet, sock_stream, 0); if(!($sock = socket_create(af_inet, sock_stream, 0))){     $errorcode = socket_last_error();     $errormsg = socket_strerror($errorcode);      die("failed create socket: [$errorcode] $errormsg \n"); } echo "socket created! \n"; socket_bind($sock, 0, 899); echo "socket bound \n"; while (true) {  socket_listen($sock, 100); echo "listening connections \n"; $client = socket_accept($sock); echo "connection established. \n"; if(socket_getpeername($client , $address, $port)){     echo "client $address : $port has established connection socket master. \n"; }  $input = socket_read($client); $request = explode("\n", $input); if($request[0] == "dovote"){     $key = $request[1];     $id = $request[2];     $player = $request[3];     $ip = $request[4];    }  elseif($request[0] == "test"){     $key = $request[1];     $id = $request[2];     $player = $request[3];     $ip = $request[4];        $querytest = ("select * socketmanager privatekey = '".$key."' , id = '".$id."'");     $resulttest = mysql_query($querytest);     if(mysql_num_rows($resultauth) == "1"){         socket_send($sock, $msg1, strlen($msg1), 0);     }     else{         socket_send($sock, $msg3, strlen($msg3), 0);     }  }  else{     if(!socket_send($sock, $msg3, strnlen($msg3), 0)){         $errorcode = socket_last_error();         $errormsg = socket_strerror($errorcode);         die("could not send data: [$errorcode] $errormsg \n");     } }    } 

i've uploaded web server, vps, control (port 899 open). whereas when on mac run:

telnet open ip 80 

it opens , closes it. on webserver, run script , see nothing except "listening connections"

i think it's permission problems:

non-root user can't bind port below 1024. selinux limitation or firewall problems. 

you should check socket_bind() , socket_listen() return true or false, debug deep it.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -