Write two programs (or one program with two modes) which run on networked computers, and send some messages between them.

The protocol used may be language-specific or not, and should be suitable for general distributed programming; that is, the protocol should be generic (not designed just for the particular example application), readily capable of handling the independent communications of many different components of a single application, and the transferring of arbitrary data structures natural for the language.

This task is intended to demonstrate high-level communication facilities beyond just creating sockets.

without js -- (zmq dll/so)
puts(1, "durapub:\n")
include zmq/zmq.e

atom context = zmq_init(1)
zmq_assert(context, "zmq_init")

--// subscriber tells us when it's ready here
atom sync = zmq_socket(context, ZMQ_PULL)
zmq_bind(sync, "tcp://*:5564")

--// send update via this socket
atom publisher = zmq_socket(context, ZMQ_PUB)
zmq_bind(publisher, "tcp://*:5565")

--// broadcast 10 updates, with pause
for update_nbr = 1 to 10 do
    string s = sprintf("Update %d", { update_nbr })
    zmq_s_send(publisher, s)
    sleep(1)
end for

zmq_s_send(publisher, "END")
sleep(1)

zmq_close(sync)
zmq_close(publisher)
zmq_term(context)
