[zeromq-dev] Pull Request: Allow clients to get origin of messages

Stefan Radomski radomski at tk.informatik.tu-darmstadt.de
Mon Jan 6 10:45:01 CET 2014

Hi there,

I just submitted a pull request that will allow client applications to retrieve the origin of messages by exposing the TCP file descriptor per message. You can get the FD via:

int srcFd = zmq_msg_get(&msg, ZMQ_SRCFD);

and then use getpeername(2) to get the origin of the message. The changes are rather small in scope: I did have to introduce a new field (fd) in the content field of a message and socket_base. There were quite some posts in the past regarding this functionality and I’d like to argue that the overhead, both in terms of runtime and memory as well as maintenance is miniscule.

At the moment, this will only work for sockets from TCP connections, messages from other sources will return -1. If this pull request finds approval, I will submit another one with updated documentation. Please review it with some scrutiny as I am not intimately familiar with the inner workings of zmq.

Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140106/30e69c5e/attachment.htm>

More information about the zeromq-dev mailing list