Here's the code!
How can i get the return by 'socket_read()"?
<?
/get the post "01 booklist select from contentlist"/
$sql = "select from music";
error_reporting(E_ALL);
/ Get the port for the WWW service. /
$service_port = 5000;
/ Get the IP address for the target host. /
$address = '192.168.0.142';
/ Create a TCP/IP socket. /
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
} else {
echo "\n";
}
$result = socket_connect($socket, $address, $service_port);
if ($result < 0) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
echo "\n";
}
//$out = '';
socket_write($socket, $sql, strlen($sql));
while ($out = socket_read($socket, 0, PHP_BINARY_READ)) {
echo "right";
}
socket_close($socket);
?>