PHP - access to shared memory created using C ++

Since several days I try to find the following: I have a tiny C ++ program that continuously reads some data from the serial port. This data is stored in shared memory as follows:

HANDLE hMapFile;
hMapFile = CreateFileMapping(
    INVALID_HANDLE_VALUE,
    NULL,
    PAGE_READWRITE,
    0,
    10,
    NULL);

LPCTSTR pBuf;
pBuf = (LPTSTR) MapViewOfFileEx(
    hMapFile,
    FILE_MAP_ALL_ACCESS,
    0,
    0,
    10,
    NULL);

while(true)
{
    //... some code ...
    CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR)));
    //... some code ...
}

Now I would like to access this shared memory using PHP. so I tried to do the following:

$shm_id = shmop_open($key, $mode, $security, $size);
$read = shmop_read($shm_id, 0, 10);
//... some code ...

But I do not know what key, mode, security and size I must install!

, - : "MapViewOfFileEx()", , PHP . "0x00030000" ++, PHP. ++ FileMapping, PHP : shmop_open(): . $mode "a" . 0777 ... $size 10 .

PHP-, , 0 $security AND $size, , .

? , BaseAdress ++ , $ PHP, PHP, ? : ++ PHP ( wamp-)?

PS: , , ... named-pipe, named-pipe? / ++ PHP?

+4
1

Redis ++ PHP. Pub/sub , . http://redis.io/topics/pubsub. redis: http://redis.io/clients

0

Source: https://habr.com/ru/post/1543396/


All Articles