Q:

how to continuously listen PHP(client.php) socket from Server(server.java)socket in socket programming

i am working with socket programming and my server socket is in java and my client program is in php. here server.java is continuouly sending data(running on command prompt). when the connection is established i got the response from server to the client.php on the browser only one time.
here the problem is that,  i want to continuously display the data on client.php(display on browser).
client.php
<?php
$host    = "192.168.1.10";
$port    = 4444;
$message = "Hello Server";
echo "Message To server :".$message;
while (true) {

// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
// connect to server
$result = socket_connect($socket, $host, $port) or die("Could not connect to server\n");  
// send string to server

socket_write($socket, $message, strlen($message)) or die("Could not send data to server\n");
// get server response

$result = socket_read ($socket, 1024) or die("Could not read server response\n");

echo "Reply From Server  :".$result ."<br>";
}

?>

A:

i found the solution. The server is continuously listening the client socket and sending the message also. just i need to display on the browser.Now solution: I am automatically refreshing the client.php socket. I don't no this is the right way to do this or not. But the output is getting right what i am expecting.
Client.php
<?php
$host    = "192.168.1.10";
$port    = 4444;
$message = "Hello Server";
echo "Message To server :".$message;
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
// connect to server
$result = socket_connect($socket, $host, $port) or die("Could not connect to server\n");  
// send string to server
if($result) { 
socket_write($socket, $message, strlen($message)) or die("Could not send data to server\n");
// get server response

$result = socket_read ($socket, 1024) or die("Could not read server response\n");
}

echo "Reply From Server  :".$result ."<br>";

// close socket
//socket_close($socket);
$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 1; URL=$url1");

?>

