1.去下载一份最新版本的帮助: http://www.php.net/distributions/manual/php_manual_en.chm2.我给的例子just for linux,如果要在2000下实现这个功能,变通的 方法很多,例如可以用Socket functions:在驻留程序开一个端口(TCP or UDP)监视,在PHP中用Socket functions连接这个端口,传递参数, 并取得返回结果,so easy.
现在在学习php socket functions: 问一下: The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-ockets option to configure. 什么意思 ?就是要在在哪设置?
exec()这些可以吗?
说明:C程序读取共享内存区,如果不为0,则输出,并清空
PHP程序对共享内存区进行写操作。
ps.可以在C程序中再开一块共享内存区,作为返回信息。
PHP程序
----------------------------------------------------
<?php
$shm_id = @shmop_open(74, "w", 0, 0);
if(!$shm_id) {
echo "Couldn't get shared memory segment\n";
exit();
}$shm_size = shmop_size($shm_id);
echo "SHM Block Size: ".$shm_size."\n";$lRet = shmop_write($shm_id, "test 1", 0);
echo "write ".$lRet." bytes to shm \n";shmop_close($shm_id);
?>
---------------------------------------------------
Ansi C 程序
---------------------------------------------------
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h> #define SHMKEY 74
#define K 1024 int shmid;
char *addr;cleanup()
{
shmdt(addr);
shmctl(shmid,IPC_RMID,0);
exit(0);
}
main()
{
int i; for (i=0;i<20;i++)
signal(i,cleanup); shmid=shmget(SHMKEY,128*K,0777|IPC_CREAT);
addr=shmat(shmid,0,0);
memset(addr,'\0',128*K);
while(1)
{
if(strncmp(addr,"")!=0)
{
printf("%s\n",addr);
memset(addr,'\0',128*K);
}
sleep(1);
}
}
---------------------------------------------------
但是,我还是有些问题,呵呵1.php程序中的shmop_read是操作共享内存的函数吧。我在php4完全 中文手册上找不到,能否给出这类些的具体用法,谢谢2.我的驻留程序是用vc6在win2000编的,它除了监视php的信息外还要监视串口信息,大侠能帮我看看vc6,win2000下怎么做监视 php?因为我vc不是很好,但现在又很急!谢谢了
http://www.php.net/distributions/manual/php_manual_en.chm2.我给的例子just for linux,如果要在2000下实现这个功能,变通的
方法很多,例如可以用Socket functions:在驻留程序开一个端口(TCP
or UDP)监视,在PHP中用Socket functions连接这个端口,传递参数,
并取得返回结果,so easy.
问一下:
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the
--enable-ockets option to configure. 什么意思 ?就是要在在哪设置?
文件,就可以使用socket functions