Search code examples
phpzeromqlibevent

Dont wait for server to respond using ZeroMQ


Today I had a look at what Rasmus described here http://toys.lerdorf.com/archives/57-ZeroMQ-+-libevent-in-PHP.html using ZeroMQ together with libevent in PHP.

I got it to work, but I noticed that the client waits for the server to return/sending a response. Is it possible to make the client script not waiting for a server response? I just want the message I sent to the server to be "fire and forget".

I googled around a bit but didnt come up with anything useful, the ZeroMQ PHP client library doesnt seem to have too many options regarding asynchronus communication or did I miss something?


Solution

  • The example uses a REP/REQ socket pair and the final recv() call isn't strictly necessary, but I would recommend you usa a PUSH/PULL pair instead (PUSH on the client, PULL on the server), then you can close the client socket right after sending. The reply part in the server must be discarded in that case.