Extract part of the content change job to Content.
[dcpomatic.git] / src / lib / nanomsg.cc
index 1180f69369930958ba3ad44cef56da5de4f4f70a..61e6c08ce9e66fa738300b9a417267356f71a8b6 100644 (file)
@@ -43,17 +43,24 @@ Nanomsg::Nanomsg (bool server)
                throw runtime_error("Could not set up nanomsg socket");
        }
        if (server) {
-               if (nn_bind(_socket, NANOMSG_URL) < 0) {
+               if ((_endpoint = nn_bind(_socket, NANOMSG_URL)) < 0) {
                        throw runtime_error(String::compose("Could not bind nanomsg socket (%1)", errno));
                }
        } else {
-               if (nn_connect(_socket, NANOMSG_URL) < 0) {
+               if ((_endpoint = nn_connect(_socket, NANOMSG_URL)) < 0) {
                        throw runtime_error(String::compose("Could not connect nanomsg socket (%1)", errno));
                }
        }
 }
 
 
+Nanomsg::~Nanomsg ()
+{
+       nn_shutdown (_socket, _endpoint);
+       nn_close (_socket);
+}
+
+
 bool
 Nanomsg::send (string s, int timeout)
 {