I have setup geth Ether testnet. I want to communicate over IPC PHP with the client. Im on Ubuntu. This is my current code:
$myValType = NULL;
$msg = "";
($key = ftok("/home/john/.ethereum/testnet/geth.ipc","="));
$queue = msg_get_queue($key);
msg_send($queue, 1, '{"jsonrpc":"2.0","method":"miner_start","params":[],"id":1}');
msg_receive($queue,0,$myValType,2048,$msg);
dd($msg); # (Die and Dump, Laravel)
This is the IPC File(FIFO?):
srwxrwxrwx 1 john john 0 Jun 17 01:30 geth.ipc=
This is working fine
echo '{"jsonrpc":"2.0","method":"rpc_modules","params":[],"id":1}' | nc -U geth.ipc
I'm not sure how to actually communicate with the client. There is no response from it when sending. On msg_receive
it just returns the initial sent message.
Someone hase expirience and be so kind and give me a proper solution?
Update: I found out how it works. I used PHP Sockets
$sock = socket_create(AF_UNIX, SOCK_STREAM, 0);
socket_connect($sock, "/home/john/.ethereum/testnet/geth.ipc",1);
$myBuf = null;
$msg = "{\"jsonrpc\":\"2.0\",\"method\":\"rpc_modules\",\"params\":[],\"id\":1}";
socket_send($sock, $msg, strlen($msg), MSG_EOF);
socket_recv ( $sock , $myBuf , 100 ,MSG_WAITALL );
Instead of using MSG Queues I could make it work with simple PHP Socket to the IPC File!