您可以使用共享内存在Windows中的php脚本和c程序之间进行通信吗?
C程序始终运行,并使用内存映射文件,即:
handle1 = CreateFileMapping(
(HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(byte)*BUFFER_SIZE, "my_foo" );
hView = (LPINT) MapViewOfFile(handle1, FILE_MAP_ALL_ACCESS, 0, 0, 0);
对于PHP脚本,我可以仅使用以下代码打开由c程序创建的内存映射文件吗?
$shmkey = @shmop_open(ftok("my_foo", 'R'), "a", 0644, $buffer_size);
还是c内存映射文件和php共享内存不同?
解决方法:
PHP shmop函数只是底层POSIX functions的包装器,在Windows下似乎不可用.
Note: Versions of Windows previous to Windows 2000 do not
support shared memory. Under Windows,
Shmop will only work when PHP is
running as a web server module, such
as Apache or IIS (CLI and CGI will not
work).
显然,PHP在apache中模拟了此行为,但是由于它在独立的二进制文件中不可用,因此很难与Windows等效项集成.
标签:shared-memory,c-3,php,ipc
来源: https://codeday.me/bug/20191210/2103368.html