Author Topic: Reading socket info with PHP  (Read 7381 times)

pjchavaux

  • Newbie
  • *
  • Posts: 5
    • View Profile
Reading socket info with PHP
« on: October 16, 2016, 12:56:23 PM »
Hi,
I am trying to retrieve a list of registered users from socket 127.0.0.1 5038 using PHP. This is the code that is failing. Any help would be greatly appreciated.
<?php
$host = "127.0.0.1";
$port = "5038";
 
print "Starting Yates Socket Server...\n";
 
 $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
 
socket_bind($sock, $host, $port);
$msgsock = socket_accept($sock);
  $msg = "nib list registered";
  sleep(2);
    socket_write($msgsock, $msg, strlen($msg));
   print "Finished writing to socket...\n";
   sleep(2);
socket_listen($sock, 4);
 
$childSocket = socket_accept($sock);
$incomingData = socket_read($childSocket, 2048);
echo "Response".$incomingData;
?>