diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-04-09 00:58:42 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-04-13 00:23:41 +0200 |
| commit | 350afcbc40fffd8c8780180e153a2ee91088f562 (patch) | |
| tree | ccbabb8b91239555ed01ca762d2f56b02858a8cf /src/lib/nanomsg.h | |
| parent | a16523af5f70b60f4890f198f6214177077a9c1d (diff) | |
Tidy up nanomsg class API; add unmounting for Linux.
Diffstat (limited to 'src/lib/nanomsg.h')
| -rw-r--r-- | src/lib/nanomsg.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/nanomsg.h b/src/lib/nanomsg.h index dc84a6ce7..9bd87098b 100644 --- a/src/lib/nanomsg.h +++ b/src/lib/nanomsg.h @@ -28,18 +28,21 @@ class Nanomsg : public boost::noncopyable public: explicit Nanomsg (bool server); - void blocking_send (std::string s); - /** Try to send a message, returning true if successful, false - * if we should try again (EAGAIN) or throwing an exception on any other - * error. + /** Try to send a message, waiting for some timeout before giving up. + * @param timeout Timeout in milliseconds, or -1 for infinite timeout. + * @return true if the send happened, false if there was a timeout. */ - bool nonblocking_send (std::string s); - std::string blocking_get (); - boost::optional<std::string> nonblocking_get (); + bool send (std::string s, int timeout); + + /** Try to receive a message, waiting for some timeout before giving up. + * @param timeout Timeout in milliseconds, or -1 for infinite timeout. + * @return Empty if the timeout was reached, otherwise the received string. + */ + boost::optional<std::string> receive (int timeout); private: boost::optional<std::string> get_from_pending (); - void recv_and_parse (bool blocking); + void recv_and_parse (int flags); int _socket; std::list<std::string> _pending; |
