projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tidy up careful_string_filter and add some extra transliterations.
[dcpomatic.git]
/
src
/
lib
/
nanomsg.cc
diff --git
a/src/lib/nanomsg.cc
b/src/lib/nanomsg.cc
index b66d966afb7cc4bd02ed5b42142b6f7cc736f9fe..8061e2f8462c2b101f01e9ea71e48ca5724c71a1 100644
(file)
--- a/
src/lib/nanomsg.cc
+++ b/
src/lib/nanomsg.cc
@@
-19,17
+19,17
@@
*/
*/
-#include "nanomsg.h"
#include "dcpomatic_log.h"
#include "exceptions.h"
#include "dcpomatic_log.h"
#include "exceptions.h"
+#include "nanomsg.h"
#include <nanomsg/nn.h>
#include <nanomsg/pair.h>
#include <nanomsg/nn.h>
#include <nanomsg/pair.h>
-#include <stdexcept>
#include <cerrno>
#include <cerrno>
+#include <stdexcept>
-using std::string;
using std::runtime_error;
using std::runtime_error;
+using std::string;
using boost::optional;
using boost::optional;
@@
-43,17
+43,24
@@
Nanomsg::Nanomsg (bool server)
throw runtime_error("Could not set up nanomsg socket");
}
if (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 {
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));
}
}
}
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)
{
bool
Nanomsg::send (string s, int timeout)
{
@@
-99,6
+106,7
@@
Nanomsg::recv_and_parse (int flags)
return;
}
return;
}
+ LOG_DISK_NC("nn_recv failed");
throw CommunicationFailedError ();
}
throw CommunicationFailedError ();
}