php多进程编程时如何共享变量
发布网友
发布时间:2022-04-29 01:50
我来回答
共1个回答
热心网友
时间:2022-04-29 10:30
<?php /**
* File name:client.php
* 客户端代码
*
* @author guisu.huang
* @since 2012-04-11
*/ set_time_limit(0);
$host = "127.0.0.1";
$port = 2046;
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)or die("Could not create socket\n"); // 创建一个Socket
$connection = socket_connect($socket, $host, $port) or die("Could not connet server\n"); // 连接 socket_write($socket, "hello socket") or die("Write failed\n"); // 数据传送 向服务器发送消息 while ($buff = socket_read($socket, 1024, PHP_NORMAL_READ)) {
echo("Response was:" . $buff . "\n");
}
socket_close($socket);