[zeromq-dev] Initial support for zmq_poll() under Java

gonzalo diethelm gdiethelm at dcv.cl
Thu Feb 25 20:24:05 CET 2010

> For an OO language, it is awkward to instantiate a Socket by hand
> when you have to pass the Context:
> s = Socket(ctx, zmq.REP)
> A better approach would be to let the context create the Socket:
> ctx.create_socket(zmq.REP)
> That way, you are sure to get the ctx argument correct.  This is
> implemented in the Python binding.

This makes sense to me.

> It is tempting to make the different socket types subclasses:
> SocketBase
> RepSocket
> ReqSocket
> P2PSocket
> Rather than using the zmq.REP|REQ... flags.  I did not implement this
> as it seemed to go too afar from the C/C++ bindings.

Or perhaps have them implement a single interface (does that exist in

> My interface to poll in modeled on Python's built-in select.poll
> It has a Poller class which you create and then call register to add
> fds/sockets:
> p = Poller()
> p.register(s1)
> p.register(s2)
> p.poll(timeout=10)
> p.unregister(s1)

How do you enquire which sockets where "signaled", and which "signals"
each of them received?

> Overall, the core API of the Python bindings follows the C/C++ very
> closely though.
> I am willing to change some of the core API of the Python bindings if
> needed but I do think it is important
> for each language to create an API that follows the spirit of the
> language.

I agree. If, for example, Python (or Ruby, or Clojure) does not support
interfaces, perhaps I will want to use them in Java anyway.

What I think we could do is to agree on a "feel" for all the
OO-languages bindings to 0MQ. For example:

* Having everything in a single package / class / namespace vs. having
separate classes.

* Being more OO (like your socket creation example above) vs. staying
close to the C/C++ API.

Gonzalo Diethelm

Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 

More information about the zeromq-dev mailing list