[zeromq-dev] problem using last endpoint sockopt in pyzmq

Chris Laws clawsicus at gmail.com
Sun Jan 13 00:33:59 CET 2013


I am trying to use a wildcard port in an effort to let the OS assign an
ephemeral port. I then try to ascertain the actual endpoint by using the
LAST_ENDPOINT socket option so that I can inform other apps of the real

This is along the lines of the suggestion here:

A simple script which demonstrates the problem is located in this gist:

The output I get when I run the script:

Python version: 2.7.2 (default, Jun 20 2012, 16:23:33)  [GCC 4.2.1
Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]
zmq version: 3.2.2
pyzmq version: 2.2dev
Endpoint is tcp://*
Traceback (most recent call last):
  File "zmq_test.py", line 38, in <module>
  File "socket.pyx", line 394, in zmq.core.socket.Socket.getsockopt
zmq.core.error.ZMQError: Invalid argument

zmq.LAST_ENDPOINT is an option listed in the constants module.

Am I doing something wrong? Is there a better way to find the actual
endpoint used when providing a wildcard port in the endpoint string to bind?

I am aware that pyzmq has the bind_to_random_port function but that does
not really fit my need exactly as that could potentially block for some
extended period of time.
In most cases it would likely be very short but I am trying to integrate
ZMQ and Twisted together so I am trying to implement a solution that avoids
blocking where ever possible.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130113/24437206/attachment.htm>

More information about the zeromq-dev mailing list