ZeroMQ – PHP client & Python server with multi part message example

Using pyobj or php data serialisation is not an option in this case..

Client:

<?php
$context = new ZMQContext();
$requester = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$requester->connect(“tcp://localhost:9999”);
$requester->send(“Filename”,ZMQ::MODE_SNDMORE);
$requester->send(“Log”,ZMQ::MODE_NOBLOCK);
?>

Server:

import zmq

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind(“tcp://*:9999”)

while True:

message = socket.recv_multipart()
print message[0]+”:”+message[1]
socket.send(“OK”,zmq.NOBLOCK)