PHP IPC with geth Ethereum How to communicate with client

0 votes

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.

Oct 22, 2018 in Blockchain by slayer
• 29,370 points
1,799 views

1 answer to this question.

0 votes

You have to use 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     );
answered Oct 22, 2018 by Omkar
• 69,220 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer

How to connect to *coin RPC-Server with PHP

If you want to connect inside your ...READ MORE

answered Sep 12, 2018 in Blockchain by slayer
• 29,370 points
1,645 views
0 votes
1 answer

How to connect to already running go ethereum client using mist Ubuntu

Hey, you can solve the issue by using sudo ...READ MORE

answered Sep 18, 2018 in Blockchain by digger
• 26,740 points
720 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,946 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,469 views
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
1,463 views
0 votes
2 answers

How to generate ethereum qr code address with amount?

You implement this package: ethereum-qr-code. It implements the EIP67 standard which uses ...READ MORE

answered Sep 6, 2018 in Blockchain by Omkar
• 69,220 points
5,105 views
0 votes
1 answer

How to reintialize genesis block in geth ethereum?

You are getting this error because you ...READ MORE

answered Dec 6, 2018 in Blockchain by Omkar
• 69,220 points
6,348 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP