|
下列代码无返回内容显示,也没有报错!
究竟问题在哪?问了好多人都没结果!
我的配置:
Apache HTTP Server Version 1.3
PHP Version 4.1.2
Redhat 7.3
按手册上说的配置应该没问题!
代码有人说socket_read()的不应为0,我改成1024,仍没显示!
<?
/*get the post "select * from music"*/
$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.1';
/* Timeout set. */
//$timeout = 15;
/* 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";
}
socket_write($socket, $sql, strlen($sql));
while ($out = socket_read($socket, 0,PHP_BINARY_READ)) {
echo $out;
}
socket_close($socket);
?>
渴望,能解决!!
相关socket_read()说明文档:
http://cn2.php.net/socket_read |
|