[zeromq-dev] Idea: Create sockets from existing FD

Goswin von Brederlow goswin-v-b at web.de
Sat Feb 1 13:32:42 CET 2014


I've been thinking of using zmq for a little daemon. But I also want
to support systemd socket activation. Now those two combined make a

ZMQ has no way to create a zmq socket given an existing FD. And socket
activation opens the sockets outside the programm and passes them in
when the program is started.

Would it be insane to have e.g.:

void *zmq_socket_from_fd(void *context, int type, int fd, bool bound);

Context and type are clear I hope. The fd would be the the file
descriptor that is already opened and bound would say wether the
socket is one that was bind()ed or one that was accept()ed/connect()ed.

This feature would also allow 2 additional use cases:

1) restarting without loosing connections (no messages dropped during

2) handling stdin / stdout
   Note: Would that need an additional flag to say wether the
         socket should allow reads or writes.


More information about the zeromq-dev mailing list