Merge pull request #889 from olafmandel/MAX_SOCKETS_MAX

Add ZMQ_MAX_SOCKETS_MAX to zmq_ctx_get()
This commit is contained in:
Pieter Hintjens 2014-02-13 19:15:01 +01:00
commit 1e9ea54bf6
5 changed files with 20 additions and 1 deletions

View File

@ -31,6 +31,11 @@ ZMQ_MAX_SOCKETS: Get maximum number of sockets
The 'ZMQ_MAX_SOCKETS' argument returns the maximum number of sockets
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
~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IPV6' argument returns the IPv6 option for the context.

View File

@ -35,7 +35,8 @@ Default value:: 1
ZMQ_MAX_SOCKETS: Set maximum number of sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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]
Default value:: 1024

View File

@ -178,6 +178,7 @@ ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
/* Context options */
#define ZMQ_IO_THREADS 1
#define ZMQ_MAX_SOCKETS 2
#define ZMQ_MAX_SOCKETS_MAX 3
/* Default for new contexts */
#define ZMQ_IO_THREADS_DFLT 1

View File

@ -24,6 +24,7 @@
#include <unistd.h>
#endif
#include <limits>
#include <new>
#include <string.h>
@ -204,6 +205,9 @@ int zmq::ctx_t::get (int option_)
if (option_ == ZMQ_MAX_SOCKETS)
rc = max_sockets;
else
if (option_ == ZMQ_MAX_SOCKETS_MAX)
rc = clipped_maxsocket (std::numeric_limits<int>::max());
else
if (option_ == ZMQ_IO_THREADS)
rc = io_thread_count;
else

View File

@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <limits>
#include "testutil.hpp"
int main (void)
@ -29,6 +30,13 @@ int main (void)
assert (ctx);
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_IPV6) == 0);