PHP socket read Data display problem
Now the buffer can be printed out using PHP to connect to the socket, and the display on the webpage is as follows:
The received data is as follows:
Response Was:1
Response Was:1
Response Was:1
Response Was:1
Response Was:1
Response Was:1
Response Was:1
Now is to put this buffer into a text box, and has been refreshed, do not know how to achieve, please the great God help. Here is my Code!
if (Isset ($_post[' button ')) {
echo "received the data as follows:";
echo "
";
$port =$_post["T2"];
$host =$_post["T1"];
Set_time_limit (0);
$socket = Socket_create (Af_inet, Sock_stream, sol_tcp) or Die ("Could not create socket\n"); Create a socket
$connection = Socket_connect ($socket, $host, $port) or Die ("Could not connet server\n"); Connection
$connection = Socket_connect ($socket, "127.0.0.1", 7777) or Die ("Could not connet server\n"); Connection
Socket_write ($socket, "hello socket") or Die ("Write failed\n"); Data transfer sends a message to the server
Ob_end_flush ();
echo Str_pad ("", 256);
while ($buffer =socket_read ($socket, 1,php_normal_read)) {
echo "Response was:". $buffer. " \ n ";
echo "
";
Flush ();
}
Socket_close ($socket);
}
if (Isset ($_post[' button2 ')) {
Socket_close ($socket);
}
?>
Share to: more
------Solutions--------------------
Response was:
.
.
.
.
echo "";