I am trying to write a pub-sub server using ZMQ.

The simplest way to describe my application is its a messaging server to
which clients connect using normal tcp sockets over intranet/internet. The
purpose is to exchange messages between them.

I am using boost::asio to implement the tcp server part of the app. So each
client connection is represented as a session object with out a thread. A
single thread reads from all the client-connections/tcp-sockets and
publishes all incoming messages to a PUB socket. ZMQ_SUB sockets are
instantiated as part of session/connection object and are connected to this
PUB socket. The transport used is inpc://.

Now the tricky part is client connections are managed using asio; means no
thread-connection pair. so i dont have a thread to wait on the SUB socket
attached to the connection. i guess i should use zmq_poll but it appears
complicated to work with if you have 10,000 SUB sockets in the server
process. It would have been great if there is a wrapper around zmq_poll  and
socket which would give something like ......

s.subscribe("topic", callback, arg)

Ideally a single threaded Reactor using zmq_poll should call the callback
function when there are messages waiting to be read from a socket similar to
how boost::asio library handles epoll internally for network sockets.
boost::asio uses proactor pattern but i guess i made my point.

Kindly advise me in this regard.

Thank you.
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to