From 5b5b513330e96e3e08d0c2c60d03044091976420 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 9 Aug 2009 09:24:48 +0200 Subject: socket options interface modeled as in BSD sockets --- include/zmq.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include/zmq.hpp') diff --git a/include/zmq.hpp b/include/zmq.hpp index 004706b..0ba972b 100644 --- a/include/zmq.hpp +++ b/include/zmq.hpp @@ -230,9 +230,15 @@ namespace zmq assert (rc == 0); } - inline void bind (const char *addr_, zmq_opts *opts_ = NULL) + template inline void setsockopt (int option_, T &value_) { - int rc = zmq_bind (ptr, addr_, opts_); + int rc = zmq_setsockopt (ptr, option_, (void*) &value_, sizeof (T)); + assert (rc == 0); + } + + inline void bind (const char *addr_) + { + int rc = zmq_bind (ptr, addr_); if (rc == -1) { assert (errno == EINVAL || errno == EADDRINUSE); if (errno == EINVAL) @@ -242,9 +248,9 @@ namespace zmq } } - inline void connect (const char *addr_, zmq_opts *opts_ = NULL) + inline void connect (const char *addr_) { - int rc = zmq_connect (ptr, addr_, opts_); + int rc = zmq_connect (ptr, addr_); if (rc == -1) { assert (errno == EINVAL || errno == EADDRINUSE); if (errno == EINVAL) -- cgit v1.2.3