diff options
author | Guido Goldstein <github@a-nugget.de> | 2011-03-12 17:16:27 +0100 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2011-03-12 17:16:27 +0100 |
commit | d0c8edde3596f512d629c6b075289ebe86488ea9 (patch) | |
tree | 812c4acd732b93c3aa276014a08ffb49970eca5c /include | |
parent | 7b95c5920c3318935b8cd8f3591cd5c65509f819 (diff) |
Added missing close method w/ check if socket is already closed.
Signed-off-by: Guido Goldstein <github@a-nugget.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/zmq.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/include/zmq.hpp b/include/zmq.hpp index 9cae990..813535f 100644 --- a/include/zmq.hpp +++ b/include/zmq.hpp @@ -214,8 +214,7 @@ namespace zmq inline ~socket_t () { - int rc = zmq_close (ptr); - assert (rc == 0); + close(); } inline operator void* () @@ -223,6 +222,17 @@ namespace zmq return ptr; } + inline void close() + { + if(ptr == NULL) + // already closed + return ; + int rc = zmq_close (ptr); + if (rc != 0) + throw error_t (); + ptr = 0 ; + } + inline void setsockopt (int option_, const void *optval_, size_t optvallen_) { |