diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-26 00:22:40 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-26 02:21:16 +0100 |
| commit | 818e4bec3fd59a4ff7619a1b449c4eda71cb84fb (patch) | |
| tree | b0be2ffc8113abe037c3f4652b2db09b4e54cf47 /src/lib | |
| parent | 2d777cdbd6017463fe6bd62e2d982d273811d7de (diff) | |
Allow use of different nanomsg socket URLs for different purposes.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/nanomsg.cc | 9 | ||||
| -rw-r--r-- | src/lib/nanomsg.h | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/nanomsg.cc b/src/lib/nanomsg.cc index 8061e2f84..425009538 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -33,21 +33,22 @@ using std::string; using boost::optional; -#define NANOMSG_URL "ipc:///tmp/dcpomatic.ipc" +char constexpr URL_PREFIX[] = "ipc:///tmp/dcpomatic_"; -Nanomsg::Nanomsg (bool server) +Nanomsg::Nanomsg(bool server, string id) { _socket = nn_socket (AF_SP, NN_PAIR); if (_socket < 0) { throw runtime_error("Could not set up nanomsg socket"); } + string const url = URL_PREFIX + id; if (server) { - if ((_endpoint = nn_bind(_socket, NANOMSG_URL)) < 0) { + if ((_endpoint = nn_bind(_socket, url.c_str())) < 0) { throw runtime_error(String::compose("Could not bind nanomsg socket (%1)", errno)); } } else { - if ((_endpoint = nn_connect(_socket, NANOMSG_URL)) < 0) { + if ((_endpoint = nn_connect(_socket, url.c_str())) < 0) { throw runtime_error(String::compose("Could not connect nanomsg socket (%1)", errno)); } } diff --git a/src/lib/nanomsg.h b/src/lib/nanomsg.h index 8d89d6d99..8ae6a55aa 100644 --- a/src/lib/nanomsg.h +++ b/src/lib/nanomsg.h @@ -27,7 +27,7 @@ class Nanomsg { public: - explicit Nanomsg (bool server); + Nanomsg(bool server, std::string prefix); ~Nanomsg (); Nanomsg (Nanomsg const&) = delete; |
