Commit 5815b768 authored by Olaf Mandel's avatar Olaf Mandel

Add ZMQ_MAX_SOCKETS_MAX to zmq_ctx_get()

The new options allows querying the maximum allowed number of sockets.
This is system dependent and cannot be encoded in the include file as a
preprocessor macro: for ZMQ_USE_SELECT, this depends on the FD_SETSIZE
macro at time of library compilation, not at time of include file use.
parent b54a168d
...@@ -31,6 +31,11 @@ ZMQ_MAX_SOCKETS: Get maximum number of sockets ...@@ -31,6 +31,11 @@ ZMQ_MAX_SOCKETS: Get maximum number of sockets
The 'ZMQ_MAX_SOCKETS' argument returns the maximum number of sockets The 'ZMQ_MAX_SOCKETS' argument returns the maximum number of sockets
allowed for this context. allowed for this context.
ZMQ_MAX_SOCKETS_MAX: Get largest configurable number of sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_MAX_SOCKETS_MAX' argument returns the largest number of sockets
that linkzmq:zmq_ctx_set[3] will accept.
ZMQ_IPV6: Set IPv6 option ZMQ_IPV6: Set IPv6 option
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IPV6' argument returns the IPv6 option for the context. The 'ZMQ_IPV6' argument returns the IPv6 option for the context.
......
...@@ -35,7 +35,8 @@ Default value:: 1 ...@@ -35,7 +35,8 @@ Default value:: 1
ZMQ_MAX_SOCKETS: Set maximum number of sockets ZMQ_MAX_SOCKETS: Set maximum number of sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_MAX_SOCKETS' argument sets the maximum number of sockets allowed The 'ZMQ_MAX_SOCKETS' argument sets the maximum number of sockets allowed
on the context. on the context. You can query the maximal allowed value with
linkzmq:zmq_ctx_get[3] using 'option_name' set to 'ZMQ_MAX_SOCKETS_MAX'.
[horizontal] [horizontal]
Default value:: 1024 Default value:: 1024
......
...@@ -178,6 +178,7 @@ ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch); ...@@ -178,6 +178,7 @@ ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
/* Context options */ /* Context options */
#define ZMQ_IO_THREADS 1 #define ZMQ_IO_THREADS 1
#define ZMQ_MAX_SOCKETS 2 #define ZMQ_MAX_SOCKETS 2
#define ZMQ_MAX_SOCKETS_MAX 3
/* Default for new contexts */ /* Default for new contexts */
#define ZMQ_IO_THREADS_DFLT 1 #define ZMQ_IO_THREADS_DFLT 1
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <limits>
#include <new> #include <new>
#include <string.h> #include <string.h>
...@@ -204,6 +205,9 @@ int zmq::ctx_t::get (int option_) ...@@ -204,6 +205,9 @@ int zmq::ctx_t::get (int option_)
if (option_ == ZMQ_MAX_SOCKETS) if (option_ == ZMQ_MAX_SOCKETS)
rc = max_sockets; rc = max_sockets;
else else
if (option_ == ZMQ_MAX_SOCKETS_MAX)
rc = clipped_maxsocket (std::numeric_limits<int>::max());
else
if (option_ == ZMQ_IO_THREADS) if (option_ == ZMQ_IO_THREADS)
rc = io_thread_count; rc = io_thread_count;
else else
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <limits>
#include "testutil.hpp" #include "testutil.hpp"
int main (void) int main (void)
...@@ -29,6 +30,13 @@ int main (void) ...@@ -29,6 +30,13 @@ int main (void)
assert (ctx); assert (ctx);
assert (zmq_ctx_get (ctx, ZMQ_MAX_SOCKETS) == ZMQ_MAX_SOCKETS_DFLT); assert (zmq_ctx_get (ctx, ZMQ_MAX_SOCKETS) == ZMQ_MAX_SOCKETS_DFLT);
#if defined(ZMQ_USE_SELECT)
assert (zmq_ctx_get (ctx, ZMQ_MAX_SOCKETS_MAX) == ZMQ_MAX_SOCKETS_DFLT);
#elif defined(ZMQ_USE_POLL) || defined(ZMQ_USE_EPOLL) \
|| defined(ZMQ_USE_DEVPOLL) || defined(ZMQ_USE_KQUEUE)
assert (zmq_ctx_get (ctx, ZMQ_MAX_SOCKETS_MAX)
== std::numeric_limits<int>::max());
#endif
assert (zmq_ctx_get (ctx, ZMQ_IO_THREADS) == ZMQ_IO_THREADS_DFLT); assert (zmq_ctx_get (ctx, ZMQ_IO_THREADS) == ZMQ_IO_THREADS_DFLT);
assert (zmq_ctx_get (ctx, ZMQ_IPV6) == 0); assert (zmq_ctx_get (ctx, ZMQ_IPV6) == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment