rbczmq 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -3
- data/ext/czmq.tar.gz +0 -0
- data/ext/rbczmq/context.c +46 -0
- data/ext/rbczmq/extconf.rb +1 -1
- data/ext/rbczmq/frame.c +1 -0
- data/ext/rbczmq/loop.c +0 -10
- data/ext/rbczmq/pollitem.c +3 -0
- data/ext/rbczmq/pollitem.h +4 -0
- data/ext/rbczmq/rbczmq_ext.c +10 -0
- data/ext/rbczmq/rbczmq_ext.h +5 -0
- data/ext/rbczmq/socket.c +129 -47
- data/ext/rbczmq/socket.h +1 -1
- data/ext/rbczmq/timer.c +0 -4
- data/ext/zeromq.tar.gz +0 -0
- data/lib/zmq/loop.rb +0 -9
- data/lib/zmq/version.rb +1 -1
- data/test/test_context.rb +15 -1
- data/test/test_pollitem.rb +11 -1
- data/test/test_socket.rb +27 -0
- data/test/test_zmq.rb +1 -1
- metadata +8 -8
    
        data/README.rdoc
    CHANGED
    
    | @@ -231,16 +231,14 @@ Running tests | |
| 231 231 | 
             
            * OS X leaks utility - http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/leaks.1.html
         | 
| 232 232 | 
             
            * Handle GC issue with timers in loop callbacks
         | 
| 233 233 | 
             
            * czmq send methods aren't non-blocking by default
         | 
| 234 | 
            -
            * Enforce socket timeouts
         | 
| 235 234 | 
             
            * Revisit the ZMQ::Loop API
         | 
| 236 | 
            -
            * Push gem out to rubygems.org
         | 
| 237 235 | 
             
            * RDOC fail on mixed C and Ruby source files that document that same constants
         | 
| 238 236 | 
             
            * GC guards to prevent recycling objects being sent / received.
         | 
| 239 237 | 
             
            * Sockets can bind && connect to multiple endpoints - account for that
         | 
| 240 238 | 
             
            * Watch out for further cases where REQ / REP pairs could raise EFSM
         | 
| 241 239 | 
             
            * Do not clobber local scope from macros (James's commit in master)
         | 
| 242 | 
            -
            * Support installation without vendor'ed libs as well
         | 
| 243 240 | 
             
            * Incorporate examples into CI as well
         | 
| 241 | 
            +
            * Zero-copy semantics for frames
         | 
| 244 242 |  | 
| 245 243 | 
             
            == Contact, feedback and bugs
         | 
| 246 244 |  | 
    
        data/ext/czmq.tar.gz
    CHANGED
    
    | Binary file | 
    
        data/ext/rbczmq/context.c
    CHANGED
    
    | @@ -173,6 +173,50 @@ static VALUE rb_czmq_ctx_set_linger(VALUE obj, VALUE linger) | |
| 173 173 | 
             
                return Qnil;
         | 
| 174 174 | 
             
            }
         | 
| 175 175 |  | 
| 176 | 
            +
            /*
         | 
| 177 | 
            +
             *  call-seq:
         | 
| 178 | 
            +
             *     ctx.hwm    =>  Fixnum
         | 
| 179 | 
            +
             *
         | 
| 180 | 
            +
             *  Returns High Water Mark (HWM) option used for native thread creation (non-Ruby threads, ahead of time API addition)
         | 
| 181 | 
            +
             *
         | 
| 182 | 
            +
             * === Examples
         | 
| 183 | 
            +
             *     ctx = ZMQ::Context.new
         | 
| 184 | 
            +
             *     ctx.hwm    =>   1
         | 
| 185 | 
            +
             *
         | 
| 186 | 
            +
            */
         | 
| 187 | 
            +
             | 
| 188 | 
            +
            static VALUE rb_czmq_ctx_hwm(VALUE obj)
         | 
| 189 | 
            +
            {
         | 
| 190 | 
            +
                errno = 0;
         | 
| 191 | 
            +
                int wm;
         | 
| 192 | 
            +
                ZmqGetContext(obj);
         | 
| 193 | 
            +
                return INT2FIX(zctx_hwm(ctx->ctx));
         | 
| 194 | 
            +
            }
         | 
| 195 | 
            +
             | 
| 196 | 
            +
            /*
         | 
| 197 | 
            +
             *  call-seq:
         | 
| 198 | 
            +
             *     ctx.hwm = 100    =>  nil
         | 
| 199 | 
            +
             *
         | 
| 200 | 
            +
             *  Sets the High Water Mark (HWM) option used for native thread creation (non-Ruby threads, ahead of time API addition)
         | 
| 201 | 
            +
             *
         | 
| 202 | 
            +
             * === Examples
         | 
| 203 | 
            +
             *     ctx = ZMQ::Context.new
         | 
| 204 | 
            +
             *     ctx.hwm = 100    =>   nil
         | 
| 205 | 
            +
             *
         | 
| 206 | 
            +
            */
         | 
| 207 | 
            +
             | 
| 208 | 
            +
            static VALUE rb_czmq_ctx_set_hwm(VALUE obj, VALUE hwm)
         | 
| 209 | 
            +
            {
         | 
| 210 | 
            +
                errno = 0;
         | 
| 211 | 
            +
                int wm;
         | 
| 212 | 
            +
                ZmqGetContext(obj);
         | 
| 213 | 
            +
                Check_Type(hwm, T_FIXNUM);
         | 
| 214 | 
            +
                wm = FIX2INT(hwm);
         | 
| 215 | 
            +
                if (wm < 0) rb_raise(rb_eZmqError, "negative HWM values is not supported.");
         | 
| 216 | 
            +
                zctx_set_hwm(ctx->ctx, wm);
         | 
| 217 | 
            +
                return Qnil;
         | 
| 218 | 
            +
            }
         | 
| 219 | 
            +
             | 
| 176 220 | 
             
            /*
         | 
| 177 221 | 
             
             * :nodoc:
         | 
| 178 222 | 
             
             *  Creates a new socket while the GIL is released.
         | 
| @@ -277,4 +321,6 @@ void _init_rb_czmq_context() | |
| 277 321 | 
             
                rb_define_method(rb_cZmqContext, "iothreads=", rb_czmq_ctx_set_iothreads, 1);
         | 
| 278 322 | 
             
                rb_define_method(rb_cZmqContext, "linger=", rb_czmq_ctx_set_linger, 1);
         | 
| 279 323 | 
             
                rb_define_method(rb_cZmqContext, "socket", rb_czmq_ctx_socket, 1);
         | 
| 324 | 
            +
                rb_define_method(rb_cZmqContext, "hwm", rb_czmq_ctx_hwm, 0);
         | 
| 325 | 
            +
                rb_define_method(rb_cZmqContext, "hwm=", rb_czmq_ctx_set_hwm, 1);
         | 
| 280 326 | 
             
            }
         | 
    
        data/ext/rbczmq/extconf.rb
    CHANGED
    
    | @@ -123,7 +123,7 @@ $INCFLAGS << " -I#{czmq_include_path}" if find_header("czmq.h", czmq_include_pat | |
| 123 123 | 
             
            $LIBPATH << libs_path.to_s
         | 
| 124 124 |  | 
| 125 125 | 
             
            # Special case to prevent Rubinius compile from linking system libzmq if present
         | 
| 126 | 
            -
            if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
         | 
| 126 | 
            +
            if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/ && RUBY_PLATFORM =~ /linux/
         | 
| 127 127 | 
             
              CONFIG['LDSHARED'] = "#{CONFIG['LDSHARED']} -Wl,-rpath=#{libs_path.to_s}"
         | 
| 128 128 | 
             
            end
         | 
| 129 129 |  | 
    
        data/ext/rbczmq/frame.c
    CHANGED
    
    | @@ -381,6 +381,7 @@ void _init_rb_czmq_frame() | |
| 381 381 |  | 
| 382 382 | 
             
                rb_define_const(rb_cZmqFrame, "MORE", INT2NUM(ZFRAME_MORE));
         | 
| 383 383 | 
             
                rb_define_const(rb_cZmqFrame, "REUSE", INT2NUM(ZFRAME_REUSE));
         | 
| 384 | 
            +
                rb_define_const(rb_cZmqFrame, "DONTWAIT", INT2NUM(ZFRAME_DONTWAIT));
         | 
| 384 385 |  | 
| 385 386 | 
             
                rb_define_singleton_method(rb_cZmqFrame, "new", rb_czmq_frame_s_new, -1);
         | 
| 386 387 | 
             
                rb_define_method(rb_cZmqFrame, "destroy", rb_czmq_frame_destroy, 0);
         | 
    
        data/ext/rbczmq/loop.c
    CHANGED
    
    | @@ -1,10 +1,5 @@ | |
| 1 1 | 
             
            #include <rbczmq_ext.h>
         | 
| 2 2 |  | 
| 3 | 
            -
            static VALUE intern_call;
         | 
| 4 | 
            -
            static VALUE intern_readable;
         | 
| 5 | 
            -
            static VALUE intern_writable;
         | 
| 6 | 
            -
            static VALUE intern_error;
         | 
| 7 | 
            -
             | 
| 8 3 | 
             
            /*
         | 
| 9 4 | 
             
             * :nodoc:
         | 
| 10 5 | 
             
             *  Wraps rb_funcall to support callbacks with or without callbacks.
         | 
| @@ -393,11 +388,6 @@ static VALUE rb_czmq_loop_cancel_timer(VALUE obj, VALUE tm) | |
| 393 388 |  | 
| 394 389 | 
             
            void _init_rb_czmq_loop()
         | 
| 395 390 | 
             
            {
         | 
| 396 | 
            -
                intern_call = rb_intern("call");
         | 
| 397 | 
            -
                intern_readable = rb_intern("on_readable");
         | 
| 398 | 
            -
                intern_writable = rb_intern("on_writable");
         | 
| 399 | 
            -
                intern_error = rb_intern("on_error");
         | 
| 400 | 
            -
             | 
| 401 391 | 
             
                rb_cZmqLoop = rb_define_class_under(rb_mZmq, "Loop", rb_cObject);
         | 
| 402 392 |  | 
| 403 393 | 
             
                rb_define_alloc_func(rb_cZmqLoop, rb_czmq_loop_new);
         | 
    
        data/ext/rbczmq/pollitem.c
    CHANGED
    
    | @@ -207,6 +207,9 @@ VALUE rb_czmq_pollitem_handler(VALUE obj) | |
| 207 207 | 
             
            VALUE rb_czmq_pollitem_handler_equals(VALUE obj, VALUE handler)
         | 
| 208 208 | 
             
            {
         | 
| 209 209 | 
             
                ZmqGetPollitem(obj);
         | 
| 210 | 
            +
                ZmqAssertHandler(obj, pollitem, handler, intern_error);
         | 
| 211 | 
            +
                ZmqAssertHandler(obj, pollitem, handler, intern_readable);
         | 
| 212 | 
            +
                ZmqAssertHandler(obj, pollitem, handler, intern_writable);
         | 
| 210 213 | 
             
                pollitem->handler = handler;
         | 
| 211 214 | 
             
                return Qnil;
         | 
| 212 215 | 
             
            }
         | 
    
        data/ext/rbczmq/pollitem.h
    CHANGED
    
    | @@ -16,6 +16,10 @@ typedef struct { | |
| 16 16 | 
             
                Data_Get_Struct(obj, zmq_pollitem_wrapper, pollitem); \
         | 
| 17 17 | 
             
                if (!pollitem) rb_raise(rb_eTypeError, "uninitialized ZMQ pollitem!");
         | 
| 18 18 |  | 
| 19 | 
            +
            #define ZmqAssertHandler(obj, pollitem, handler, callback) \
         | 
| 20 | 
            +
                if (!rb_respond_to(handler, (callback))) \
         | 
| 21 | 
            +
                    rb_raise(rb_eZmqError, "Pollable entity %s's handler %s expected to implement an %s callback!", RSTRING_PTR(rb_obj_as_string(rb_czmq_pollitem_pollable((obj)))), rb_obj_classname(handler), rb_id2name((callback)));
         | 
| 22 | 
            +
             | 
| 19 23 | 
             
            VALUE rb_czmq_pollitem_coerce(VALUE pollable);
         | 
| 20 24 | 
             
            VALUE rb_czmq_pollitem_pollable(VALUE obj);
         | 
| 21 25 | 
             
            VALUE rb_czmq_pollitem_events(VALUE obj);
         | 
    
        data/ext/rbczmq/rbczmq_ext.c
    CHANGED
    
    | @@ -24,6 +24,11 @@ VALUE rb_cZmqPollitem; | |
| 24 24 |  | 
| 25 25 | 
             
            st_table *frames_map = NULL;
         | 
| 26 26 |  | 
| 27 | 
            +
            VALUE intern_call;
         | 
| 28 | 
            +
            VALUE intern_readable;
         | 
| 29 | 
            +
            VALUE intern_writable;
         | 
| 30 | 
            +
            VALUE intern_error;
         | 
| 31 | 
            +
             | 
| 27 32 | 
             
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 28 33 | 
             
            rb_encoding *binary_encoding;
         | 
| 29 34 | 
             
            #endif
         | 
| @@ -152,6 +157,11 @@ void Init_rbczmq_ext() | |
| 152 157 | 
             
            {
         | 
| 153 158 | 
             
                frames_map = st_init_numtable();
         | 
| 154 159 |  | 
| 160 | 
            +
                intern_call = rb_intern("call");
         | 
| 161 | 
            +
                intern_readable = rb_intern("on_readable");
         | 
| 162 | 
            +
                intern_writable = rb_intern("on_writable");
         | 
| 163 | 
            +
                intern_error = rb_intern("on_error");
         | 
| 164 | 
            +
             | 
| 155 165 | 
             
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 156 166 | 
             
                binary_encoding = rb_enc_find("binary");
         | 
| 157 167 | 
             
            #endif
         | 
    
        data/ext/rbczmq/rbczmq_ext.h
    CHANGED
    
    | @@ -61,6 +61,11 @@ extern VALUE rb_cZmqPollitem; | |
| 61 61 |  | 
| 62 62 | 
             
            extern st_table *frames_map;
         | 
| 63 63 |  | 
| 64 | 
            +
            extern VALUE intern_call;
         | 
| 65 | 
            +
            extern VALUE intern_readable;
         | 
| 66 | 
            +
            extern VALUE intern_writable;
         | 
| 67 | 
            +
            extern VALUE intern_error;
         | 
| 68 | 
            +
             | 
| 64 69 | 
             
            #include <context.h>
         | 
| 65 70 | 
             
            #include <socket.h>
         | 
| 66 71 | 
             
            #include <frame.h>
         | 
    
        data/ext/rbczmq/socket.c
    CHANGED
    
    | @@ -60,7 +60,7 @@ void rb_czmq_free_sock_gc(void *ptr) | |
| 60 60 | 
             
                        zclock_log ("I: %s socket %p, context %p: GC free", zsocket_type_str(sock->socket), sock, sock->ctx);
         | 
| 61 61 | 
             
            /*
         | 
| 62 62 | 
             
                    XXX: cyclic dependency
         | 
| 63 | 
            -
                    #4  0x0000000100712524 in  | 
| 63 | 
            +
                    #4  0x0000000100712524 in zsocket_set_linger (linger=1, socket=<value temporarily unavailable, due to optimizations>) at zsocket.c:288
         | 
| 64 64 | 
             
                    if (sock->socket != NULL && !(sock->flags & ZMQ_SOCKET_DESTROYED)) rb_czmq_free_sock(sock);
         | 
| 65 65 | 
             
            */
         | 
| 66 66 | 
             
            #ifndef HAVE_RB_THREAD_BLOCKING_REGION
         | 
| @@ -161,7 +161,7 @@ static VALUE rb_czmq_socket_fd(VALUE obj) | |
| 161 161 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 162 162 | 
             
                GetZmqSocket(obj);
         | 
| 163 163 | 
             
                if (sock->state == ZMQ_SOCKET_PENDING) return INT2NUM(-1);
         | 
| 164 | 
            -
                return INT2NUM( | 
| 164 | 
            +
                return INT2NUM(zsocket_fd(sock->socket));
         | 
| 165 165 | 
             
            }
         | 
| 166 166 |  | 
| 167 167 | 
             
            /*
         | 
| @@ -307,10 +307,10 @@ static VALUE rb_czmq_nogvl_zstr_send(void *ptr) | |
| 307 307 | 
             
            #else
         | 
| 308 308 | 
             
                if (rb_thread_alone()) return (VALUE)zstr_send_nowait(socket->socket, args->msg);
         | 
| 309 309 | 
             
            try_writable:
         | 
| 310 | 
            -
                if (( | 
| 310 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLOUT) == ZMQ_POLLOUT) {
         | 
| 311 311 | 
             
                    return (VALUE)zstr_send_nowait(socket->socket, args->msg);
         | 
| 312 312 | 
             
                } else {
         | 
| 313 | 
            -
                    rb_thread_wait_fd( | 
| 313 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 314 314 | 
             
                    goto try_writable;
         | 
| 315 315 | 
             
                }
         | 
| 316 316 | 
             
            #endif
         | 
| @@ -331,10 +331,10 @@ static VALUE rb_czmq_nogvl_zstr_sendm(void *ptr) | |
| 331 331 | 
             
            #else
         | 
| 332 332 | 
             
                if (rb_thread_alone()) return (VALUE)zstr_sendm(socket->socket, args->msg);
         | 
| 333 333 | 
             
            try_writable:
         | 
| 334 | 
            -
                if (( | 
| 334 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLOUT) == ZMQ_POLLOUT) {
         | 
| 335 335 | 
             
                    return (VALUE)zstr_sendm(socket->socket, args->msg);
         | 
| 336 336 | 
             
                } else {
         | 
| 337 | 
            -
                    rb_thread_wait_fd( | 
| 337 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 338 338 | 
             
                    goto try_writable;
         | 
| 339 339 | 
             
                }
         | 
| 340 340 | 
             
            #endif
         | 
| @@ -421,13 +421,13 @@ static VALUE rb_czmq_nogvl_recv(void *ptr) | |
| 421 421 | 
             
                if (zlist_size(socket->str_buffer) != 0)
         | 
| 422 422 | 
             
                   return (VALUE)zlist_pop(socket->str_buffer);
         | 
| 423 423 | 
             
            try_readable:
         | 
| 424 | 
            -
                if (( | 
| 424 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLIN) == ZMQ_POLLIN) {
         | 
| 425 425 | 
             
                    do {
         | 
| 426 426 | 
             
                        zlist_append(socket->str_buffer, zstr_recv_nowait(socket->socket));
         | 
| 427 427 | 
             
                    } while (zmq_errno() != EAGAIN && zmq_errno() != EINTR);
         | 
| 428 428 | 
             
                    return (VALUE)zlist_pop(socket->str_buffer);
         | 
| 429 429 | 
             
                 } else {
         | 
| 430 | 
            -
                    rb_thread_wait_fd( | 
| 430 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 431 431 | 
             
                    goto try_readable;
         | 
| 432 432 | 
             
                 }
         | 
| 433 433 | 
             
            #endif
         | 
| @@ -515,10 +515,10 @@ static VALUE rb_czmq_nogvl_send_frame(void *ptr) | |
| 515 515 | 
             
            #else
         | 
| 516 516 | 
             
                if (rb_thread_alone()) return (VALUE)zframe_send(&(args->frame), socket->socket, args->flags);
         | 
| 517 517 | 
             
            try_writable:
         | 
| 518 | 
            -
                if (( | 
| 518 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLOUT) == ZMQ_POLLOUT) {
         | 
| 519 519 | 
             
                    return (VALUE)zframe_send(&(args->frame), socket->socket, args->flags);
         | 
| 520 520 | 
             
                } else {
         | 
| 521 | 
            -
                    rb_thread_wait_fd( | 
| 521 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 522 522 | 
             
                    goto try_writable;
         | 
| 523 523 | 
             
                }
         | 
| 524 524 | 
             
            #endif
         | 
| @@ -596,10 +596,10 @@ static VALUE rb_czmq_nogvl_send_message(void *ptr) | |
| 596 596 | 
             
                    return Qnil;
         | 
| 597 597 | 
             
                }
         | 
| 598 598 | 
             
            try_writable:
         | 
| 599 | 
            -
                if (( | 
| 599 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLOUT) == ZMQ_POLLOUT) {
         | 
| 600 600 | 
             
                    zmsg_send(&(args->message), socket->socket);
         | 
| 601 601 | 
             
                } else {
         | 
| 602 | 
            -
                    rb_thread_wait_fd( | 
| 602 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 603 603 | 
             
                    goto try_writable;
         | 
| 604 604 | 
             
                }
         | 
| 605 605 | 
             
            #endif
         | 
| @@ -656,13 +656,13 @@ static VALUE rb_czmq_nogvl_recv_frame(void *ptr) | |
| 656 656 | 
             
                if (zlist_size(socket->frame_buffer) != 0)
         | 
| 657 657 | 
             
                   return (VALUE)zlist_pop(socket->frame_buffer);
         | 
| 658 658 | 
             
            try_readable:
         | 
| 659 | 
            -
                if (( | 
| 659 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLIN) == ZMQ_POLLIN) {
         | 
| 660 660 | 
             
                    do {
         | 
| 661 661 | 
             
                        zlist_append(socket->frame_buffer, zframe_recv_nowait(socket->socket));
         | 
| 662 662 | 
             
                    } while (zmq_errno() != EAGAIN && zmq_errno() != EINTR);
         | 
| 663 663 | 
             
                    return (VALUE)zlist_pop(socket->frame_buffer);
         | 
| 664 664 | 
             
                 } else {
         | 
| 665 | 
            -
                    rb_thread_wait_fd( | 
| 665 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 666 666 | 
             
                    goto try_readable;
         | 
| 667 667 | 
             
                 }
         | 
| 668 668 | 
             
            #endif
         | 
| @@ -751,13 +751,13 @@ static VALUE rb_czmq_nogvl_recv_message(void *ptr) | |
| 751 751 | 
             
                if (zlist_size(socket->msg_buffer) != 0)
         | 
| 752 752 | 
             
                   return (VALUE)zlist_pop(socket->msg_buffer);
         | 
| 753 753 | 
             
            try_readable:
         | 
| 754 | 
            -
                if (( | 
| 754 | 
            +
                if ((zsocket_events(socket->socket) & ZMQ_POLLIN) == ZMQ_POLLIN) {
         | 
| 755 755 | 
             
                    do {
         | 
| 756 756 | 
             
                        zlist_append(socket->msg_buffer, zmsg_recv(socket->socket));
         | 
| 757 757 | 
             
                    } while (zmq_errno() != EAGAIN && zmq_errno() != EINTR);
         | 
| 758 758 | 
             
                    return (VALUE)zlist_pop(socket->msg_buffer);
         | 
| 759 759 | 
             
                 } else {
         | 
| 760 | 
            -
                    rb_thread_wait_fd( | 
| 760 | 
            +
                    rb_thread_wait_fd(zsocket_fd(socket->socket));
         | 
| 761 761 | 
             
                    goto try_readable;
         | 
| 762 762 | 
             
                 }
         | 
| 763 763 | 
             
            #endif
         | 
| @@ -895,7 +895,7 @@ static VALUE rb_czmq_socket_opt_hwm(VALUE obj) | |
| 895 895 | 
             
            {
         | 
| 896 896 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 897 897 | 
             
                GetZmqSocket(obj);
         | 
| 898 | 
            -
                return INT2NUM( | 
| 898 | 
            +
                return INT2NUM(zsocket_hwm(sock->socket));
         | 
| 899 899 | 
             
            }
         | 
| 900 900 |  | 
| 901 901 | 
             
            /*
         | 
| @@ -915,7 +915,7 @@ static VALUE rb_czmq_socket_opt_hwm(VALUE obj) | |
| 915 915 | 
             
            static VALUE rb_czmq_socket_set_opt_hwm(VALUE obj, VALUE value)
         | 
| 916 916 | 
             
            {
         | 
| 917 917 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 918 | 
            -
                ZmqSetSockOpt(obj,  | 
| 918 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_hwm, "HWM", value);
         | 
| 919 919 | 
             
            }
         | 
| 920 920 |  | 
| 921 921 | 
             
            /*
         | 
| @@ -935,7 +935,7 @@ static VALUE rb_czmq_socket_opt_swap(VALUE obj) | |
| 935 935 | 
             
            {
         | 
| 936 936 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 937 937 | 
             
                GetZmqSocket(obj);
         | 
| 938 | 
            -
                return INT2NUM( | 
| 938 | 
            +
                return INT2NUM(zsocket_swap(sock->socket));
         | 
| 939 939 | 
             
            }
         | 
| 940 940 |  | 
| 941 941 | 
             
            /*
         | 
| @@ -954,7 +954,7 @@ static VALUE rb_czmq_socket_opt_swap(VALUE obj) | |
| 954 954 | 
             
            static VALUE rb_czmq_socket_set_opt_swap(VALUE obj, VALUE value)
         | 
| 955 955 | 
             
            {
         | 
| 956 956 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 957 | 
            -
                ZmqSetSockOpt(obj,  | 
| 957 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_swap, "SWAP", value);
         | 
| 958 958 | 
             
            }
         | 
| 959 959 |  | 
| 960 960 | 
             
            /*
         | 
| @@ -974,7 +974,7 @@ static VALUE rb_czmq_socket_opt_affinity(VALUE obj) | |
| 974 974 | 
             
            {
         | 
| 975 975 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 976 976 | 
             
                GetZmqSocket(obj);
         | 
| 977 | 
            -
                return INT2NUM( | 
| 977 | 
            +
                return INT2NUM(zsocket_affinity(sock->socket));
         | 
| 978 978 | 
             
            }
         | 
| 979 979 |  | 
| 980 980 | 
             
            /*
         | 
| @@ -993,7 +993,7 @@ static VALUE rb_czmq_socket_opt_affinity(VALUE obj) | |
| 993 993 | 
             
            static VALUE rb_czmq_socket_set_opt_affinity(VALUE obj, VALUE value)
         | 
| 994 994 | 
             
            {
         | 
| 995 995 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 996 | 
            -
                ZmqSetSockOpt(obj,  | 
| 996 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_affinity, "AFFINITY", value);
         | 
| 997 997 | 
             
            }
         | 
| 998 998 |  | 
| 999 999 | 
             
            /*
         | 
| @@ -1013,7 +1013,7 @@ static VALUE rb_czmq_socket_opt_rate(VALUE obj) | |
| 1013 1013 | 
             
            {
         | 
| 1014 1014 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1015 1015 | 
             
                GetZmqSocket(obj);
         | 
| 1016 | 
            -
                return INT2NUM( | 
| 1016 | 
            +
                return INT2NUM(zsocket_rate(sock->socket));
         | 
| 1017 1017 | 
             
            }
         | 
| 1018 1018 |  | 
| 1019 1019 | 
             
            /*
         | 
| @@ -1032,7 +1032,7 @@ static VALUE rb_czmq_socket_opt_rate(VALUE obj) | |
| 1032 1032 | 
             
            static VALUE rb_czmq_socket_set_opt_rate(VALUE obj, VALUE value)
         | 
| 1033 1033 | 
             
            {
         | 
| 1034 1034 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1035 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1035 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_rate, "RATE", value);
         | 
| 1036 1036 | 
             
            }
         | 
| 1037 1037 |  | 
| 1038 1038 | 
             
            /*
         | 
| @@ -1052,7 +1052,7 @@ static VALUE rb_czmq_socket_opt_recovery_ivl(VALUE obj) | |
| 1052 1052 | 
             
            {
         | 
| 1053 1053 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1054 1054 | 
             
                GetZmqSocket(obj);
         | 
| 1055 | 
            -
                return INT2NUM( | 
| 1055 | 
            +
                return INT2NUM(zsocket_recovery_ivl(sock->socket));
         | 
| 1056 1056 | 
             
            }
         | 
| 1057 1057 |  | 
| 1058 1058 | 
             
            /*
         | 
| @@ -1071,7 +1071,7 @@ static VALUE rb_czmq_socket_opt_recovery_ivl(VALUE obj) | |
| 1071 1071 | 
             
            static VALUE rb_czmq_socket_set_opt_recovery_ivl(VALUE obj, VALUE value)
         | 
| 1072 1072 | 
             
            {
         | 
| 1073 1073 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1074 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1074 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_recovery_ivl, "RECOVERY_IVL", value);
         | 
| 1075 1075 | 
             
            }
         | 
| 1076 1076 |  | 
| 1077 1077 | 
             
            /*
         | 
| @@ -1091,7 +1091,7 @@ static VALUE rb_czmq_socket_opt_recovery_ivl_msec(VALUE obj) | |
| 1091 1091 | 
             
            {
         | 
| 1092 1092 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1093 1093 | 
             
                GetZmqSocket(obj);
         | 
| 1094 | 
            -
                return INT2NUM( | 
| 1094 | 
            +
                return INT2NUM(zsocket_recovery_ivl_msec(sock->socket));
         | 
| 1095 1095 | 
             
            }
         | 
| 1096 1096 |  | 
| 1097 1097 | 
             
            /*
         | 
| @@ -1110,7 +1110,7 @@ static VALUE rb_czmq_socket_opt_recovery_ivl_msec(VALUE obj) | |
| 1110 1110 | 
             
            static VALUE rb_czmq_socket_set_opt_recovery_ivl_msec(VALUE obj, VALUE value)
         | 
| 1111 1111 | 
             
            {
         | 
| 1112 1112 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1113 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1113 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_recovery_ivl_msec, "RECOVERY_IVL_MSEC", value);
         | 
| 1114 1114 | 
             
            }
         | 
| 1115 1115 |  | 
| 1116 1116 | 
             
            /*
         | 
| @@ -1130,7 +1130,7 @@ static VALUE rb_czmq_socket_opt_mcast_loop(VALUE obj) | |
| 1130 1130 | 
             
            {
         | 
| 1131 1131 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1132 1132 | 
             
                GetZmqSocket(obj);
         | 
| 1133 | 
            -
                return ( | 
| 1133 | 
            +
                return (zsocket_mcast_loop(sock->socket) == 1) ? Qtrue : Qfalse;
         | 
| 1134 1134 | 
             
            }
         | 
| 1135 1135 |  | 
| 1136 1136 | 
             
            /*
         | 
| @@ -1149,7 +1149,7 @@ static VALUE rb_czmq_socket_opt_mcast_loop(VALUE obj) | |
| 1149 1149 | 
             
            static VALUE rb_czmq_socket_set_opt_mcast_loop(VALUE obj, VALUE value)
         | 
| 1150 1150 | 
             
            {
         | 
| 1151 1151 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1152 | 
            -
                ZmqSetBooleanSockOpt(obj,  | 
| 1152 | 
            +
                ZmqSetBooleanSockOpt(obj, zsocket_set_mcast_loop, "MCAST_LOOP", value);
         | 
| 1153 1153 | 
             
            }
         | 
| 1154 1154 |  | 
| 1155 1155 | 
             
            /*
         | 
| @@ -1169,7 +1169,7 @@ static VALUE rb_czmq_socket_opt_sndbuf(VALUE obj) | |
| 1169 1169 | 
             
            {
         | 
| 1170 1170 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1171 1171 | 
             
                GetZmqSocket(obj);
         | 
| 1172 | 
            -
                return INT2NUM( | 
| 1172 | 
            +
                return INT2NUM(zsocket_sndbuf(sock->socket));
         | 
| 1173 1173 | 
             
            }
         | 
| 1174 1174 |  | 
| 1175 1175 | 
             
            /*
         | 
| @@ -1188,7 +1188,7 @@ static VALUE rb_czmq_socket_opt_sndbuf(VALUE obj) | |
| 1188 1188 | 
             
            static VALUE rb_czmq_socket_set_opt_sndbuf(VALUE obj, VALUE value)
         | 
| 1189 1189 | 
             
            {
         | 
| 1190 1190 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1191 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1191 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_sndbuf, "SNDBUF", value);
         | 
| 1192 1192 | 
             
            }
         | 
| 1193 1193 |  | 
| 1194 1194 | 
             
            /*
         | 
| @@ -1208,7 +1208,7 @@ static VALUE rb_czmq_socket_opt_rcvbuf(VALUE obj) | |
| 1208 1208 | 
             
            {
         | 
| 1209 1209 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1210 1210 | 
             
                GetZmqSocket(obj);
         | 
| 1211 | 
            -
                return INT2NUM( | 
| 1211 | 
            +
                return INT2NUM(zsocket_rcvbuf(sock->socket));
         | 
| 1212 1212 | 
             
            }
         | 
| 1213 1213 |  | 
| 1214 1214 | 
             
            /*
         | 
| @@ -1227,7 +1227,7 @@ static VALUE rb_czmq_socket_opt_rcvbuf(VALUE obj) | |
| 1227 1227 | 
             
            static VALUE rb_czmq_socket_set_opt_rcvbuf(VALUE obj, VALUE value)
         | 
| 1228 1228 | 
             
            {
         | 
| 1229 1229 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1230 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1230 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_rcvbuf, "RCVBUF", value);
         | 
| 1231 1231 | 
             
            }
         | 
| 1232 1232 |  | 
| 1233 1233 | 
             
            /*
         | 
| @@ -1247,7 +1247,7 @@ static VALUE rb_czmq_socket_opt_linger(VALUE obj) | |
| 1247 1247 | 
             
            {
         | 
| 1248 1248 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1249 1249 | 
             
                GetZmqSocket(obj);
         | 
| 1250 | 
            -
                return INT2NUM( | 
| 1250 | 
            +
                return INT2NUM(zsocket_linger(sock->socket));
         | 
| 1251 1251 | 
             
            }
         | 
| 1252 1252 |  | 
| 1253 1253 | 
             
            /*
         | 
| @@ -1266,7 +1266,7 @@ static VALUE rb_czmq_socket_opt_linger(VALUE obj) | |
| 1266 1266 | 
             
            static VALUE rb_czmq_socket_set_opt_linger(VALUE obj, VALUE value)
         | 
| 1267 1267 | 
             
            {
         | 
| 1268 1268 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1269 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1269 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_linger, "LINGER", value);
         | 
| 1270 1270 | 
             
            }
         | 
| 1271 1271 |  | 
| 1272 1272 | 
             
            /*
         | 
| @@ -1286,7 +1286,7 @@ static VALUE rb_czmq_socket_opt_backlog(VALUE obj) | |
| 1286 1286 | 
             
            {
         | 
| 1287 1287 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1288 1288 | 
             
                GetZmqSocket(obj);
         | 
| 1289 | 
            -
                return INT2NUM( | 
| 1289 | 
            +
                return INT2NUM(zsocket_backlog(sock->socket));
         | 
| 1290 1290 | 
             
            }
         | 
| 1291 1291 |  | 
| 1292 1292 | 
             
            /*
         | 
| @@ -1305,7 +1305,7 @@ static VALUE rb_czmq_socket_opt_backlog(VALUE obj) | |
| 1305 1305 | 
             
            static VALUE rb_czmq_socket_set_opt_backlog(VALUE obj, VALUE value)
         | 
| 1306 1306 | 
             
            {
         | 
| 1307 1307 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1308 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1308 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_backlog, "BACKLOG", value);
         | 
| 1309 1309 | 
             
            }
         | 
| 1310 1310 |  | 
| 1311 1311 | 
             
            /*
         | 
| @@ -1325,7 +1325,7 @@ static VALUE rb_czmq_socket_opt_reconnect_ivl(VALUE obj) | |
| 1325 1325 | 
             
            {
         | 
| 1326 1326 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1327 1327 | 
             
                GetZmqSocket(obj);
         | 
| 1328 | 
            -
                return INT2NUM( | 
| 1328 | 
            +
                return INT2NUM(zsocket_reconnect_ivl(sock->socket));
         | 
| 1329 1329 | 
             
            }
         | 
| 1330 1330 |  | 
| 1331 1331 | 
             
            /*
         | 
| @@ -1344,7 +1344,7 @@ static VALUE rb_czmq_socket_opt_reconnect_ivl(VALUE obj) | |
| 1344 1344 | 
             
            static VALUE rb_czmq_socket_set_opt_reconnect_ivl(VALUE obj, VALUE value)
         | 
| 1345 1345 | 
             
            {
         | 
| 1346 1346 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1347 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1347 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_reconnect_ivl, "RECONNECT_IVL", value);
         | 
| 1348 1348 | 
             
            }
         | 
| 1349 1349 |  | 
| 1350 1350 | 
             
            /*
         | 
| @@ -1364,7 +1364,7 @@ static VALUE rb_czmq_socket_opt_reconnect_ivl_max(VALUE obj) | |
| 1364 1364 | 
             
            {
         | 
| 1365 1365 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1366 1366 | 
             
                GetZmqSocket(obj);
         | 
| 1367 | 
            -
                return INT2NUM( | 
| 1367 | 
            +
                return INT2NUM(zsocket_reconnect_ivl_max(sock->socket));
         | 
| 1368 1368 | 
             
            }
         | 
| 1369 1369 |  | 
| 1370 1370 | 
             
            /*
         | 
| @@ -1383,7 +1383,7 @@ static VALUE rb_czmq_socket_opt_reconnect_ivl_max(VALUE obj) | |
| 1383 1383 | 
             
            static VALUE rb_czmq_socket_set_opt_reconnect_ivl_max(VALUE obj, VALUE value)
         | 
| 1384 1384 | 
             
            {
         | 
| 1385 1385 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1386 | 
            -
                ZmqSetSockOpt(obj,  | 
| 1386 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_reconnect_ivl_max, "RECONNECT_IVL_MAX", value);
         | 
| 1387 1387 | 
             
            }
         | 
| 1388 1388 |  | 
| 1389 1389 | 
             
            /*
         | 
| @@ -1409,7 +1409,7 @@ static VALUE rb_czmq_socket_set_opt_identity(VALUE obj, VALUE value) | |
| 1409 1409 | 
             
                if (RSTRING_LEN(value) == 0) rb_raise(rb_eZmqError, "socket identity cannot be empty.");
         | 
| 1410 1410 | 
             
                if (RSTRING_LEN(value) > 255) rb_raise(rb_eZmqError, "maximum socket identity is 255 chars.");
         | 
| 1411 1411 | 
             
                val = StringValueCStr(value);
         | 
| 1412 | 
            -
                 | 
| 1412 | 
            +
                zsocket_set_identity(sock->socket, val);
         | 
| 1413 1413 | 
             
                if (sock->verbose)
         | 
| 1414 1414 | 
             
                    zclock_log ("I: %s socket %p: set option \"IDENTITY\" \"%s\"", zsocket_type_str(sock->socket), obj, val);
         | 
| 1415 1415 | 
             
                return Qnil;
         | 
| @@ -1431,7 +1431,7 @@ static VALUE rb_czmq_socket_set_opt_identity(VALUE obj, VALUE value) | |
| 1431 1431 | 
             
            static VALUE rb_czmq_socket_set_opt_subscribe(VALUE obj, VALUE value)
         | 
| 1432 1432 | 
             
            {
         | 
| 1433 1433 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1434 | 
            -
                ZmqSetStringSockOpt(obj,  | 
| 1434 | 
            +
                ZmqSetStringSockOpt(obj, zsocket_set_subscribe, "SUBSCRIBE", value, {
         | 
| 1435 1435 | 
             
                   ZmqAssertSockOptFor(ZMQ_SUB)
         | 
| 1436 1436 | 
             
                });
         | 
| 1437 1437 | 
             
            }
         | 
| @@ -1452,7 +1452,7 @@ static VALUE rb_czmq_socket_set_opt_subscribe(VALUE obj, VALUE value) | |
| 1452 1452 | 
             
            static VALUE rb_czmq_socket_set_opt_unsubscribe(VALUE obj, VALUE value)
         | 
| 1453 1453 | 
             
            {
         | 
| 1454 1454 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1455 | 
            -
                ZmqSetStringSockOpt(obj,  | 
| 1455 | 
            +
                ZmqSetStringSockOpt(obj, zsocket_set_unsubscribe, "UNSUBSCRIBE", value, {
         | 
| 1456 1456 | 
             
                   ZmqAssertSockOptFor(ZMQ_SUB)
         | 
| 1457 1457 | 
             
                });
         | 
| 1458 1458 | 
             
            }
         | 
| @@ -1474,7 +1474,7 @@ static VALUE rb_czmq_socket_opt_rcvmore(VALUE obj) | |
| 1474 1474 | 
             
            {
         | 
| 1475 1475 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1476 1476 | 
             
                GetZmqSocket(obj);
         | 
| 1477 | 
            -
                return ( | 
| 1477 | 
            +
                return (zsocket_rcvmore(sock->socket) == 1) ? Qtrue : Qfalse;
         | 
| 1478 1478 | 
             
            }
         | 
| 1479 1479 |  | 
| 1480 1480 | 
             
            /*
         | 
| @@ -1494,7 +1494,85 @@ static VALUE rb_czmq_socket_opt_events(VALUE obj) | |
| 1494 1494 | 
             
            {
         | 
| 1495 1495 | 
             
                zmq_sock_wrapper *sock = NULL;
         | 
| 1496 1496 | 
             
                GetZmqSocket(obj);
         | 
| 1497 | 
            -
                return INT2NUM( | 
| 1497 | 
            +
                return INT2NUM(zsocket_events(sock->socket));
         | 
| 1498 | 
            +
            }
         | 
| 1499 | 
            +
             | 
| 1500 | 
            +
            /*
         | 
| 1501 | 
            +
             *  call-seq:
         | 
| 1502 | 
            +
             *     sock.rcvtimeo =>  Fixnum
         | 
| 1503 | 
            +
             *
         | 
| 1504 | 
            +
             *  Returns the socket RCVTIMEO value.
         | 
| 1505 | 
            +
             *
         | 
| 1506 | 
            +
             * === Examples
         | 
| 1507 | 
            +
             *     ctx = ZMQ::Context.new
         | 
| 1508 | 
            +
             *     sock = ctx.socket(:REP)
         | 
| 1509 | 
            +
             *     sock.rcvtimeo  =>  -1
         | 
| 1510 | 
            +
             *
         | 
| 1511 | 
            +
            */
         | 
| 1512 | 
            +
             | 
| 1513 | 
            +
            static VALUE rb_czmq_socket_opt_rcvtimeo(VALUE obj)
         | 
| 1514 | 
            +
            {
         | 
| 1515 | 
            +
                zmq_sock_wrapper *sock = NULL;
         | 
| 1516 | 
            +
                GetZmqSocket(obj);
         | 
| 1517 | 
            +
                return INT2NUM(zsocket_rcvtimeo(sock->socket));
         | 
| 1518 | 
            +
            }
         | 
| 1519 | 
            +
             | 
| 1520 | 
            +
            /*
         | 
| 1521 | 
            +
             *  call-seq:
         | 
| 1522 | 
            +
             *     sock.rcvtimeout = 200 =>  nil
         | 
| 1523 | 
            +
             *
         | 
| 1524 | 
            +
             *  Sets the socket RCVTIMEO value.
         | 
| 1525 | 
            +
             *
         | 
| 1526 | 
            +
             * === Examples
         | 
| 1527 | 
            +
             *     ctx = ZMQ::Context.new
         | 
| 1528 | 
            +
             *     sock = ctx.socket(:REP)
         | 
| 1529 | 
            +
             *     sock.rcvtimeo = 200  =>  nil
         | 
| 1530 | 
            +
             *
         | 
| 1531 | 
            +
            */
         | 
| 1532 | 
            +
             | 
| 1533 | 
            +
            static VALUE rb_czmq_socket_set_opt_rcvtimeo(VALUE obj, VALUE value)
         | 
| 1534 | 
            +
            {
         | 
| 1535 | 
            +
                zmq_sock_wrapper *sock = NULL;
         | 
| 1536 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_rcvtimeo, "RCVTIMEO", value);
         | 
| 1537 | 
            +
            }
         | 
| 1538 | 
            +
             | 
| 1539 | 
            +
            /*
         | 
| 1540 | 
            +
             *  call-seq:
         | 
| 1541 | 
            +
             *     sock.sndtimeo =>  Fixnum
         | 
| 1542 | 
            +
             *
         | 
| 1543 | 
            +
             *  Returns the socket SNDTIMEO value.
         | 
| 1544 | 
            +
             *
         | 
| 1545 | 
            +
             * === Examples
         | 
| 1546 | 
            +
             *     ctx = ZMQ::Context.new
         | 
| 1547 | 
            +
             *     sock = ctx.socket(:REP)
         | 
| 1548 | 
            +
             *     sock.sndtimeo  =>  -1
         | 
| 1549 | 
            +
             *
         | 
| 1550 | 
            +
            */
         | 
| 1551 | 
            +
             | 
| 1552 | 
            +
            static VALUE rb_czmq_socket_opt_sndtimeo(VALUE obj)
         | 
| 1553 | 
            +
            {
         | 
| 1554 | 
            +
                zmq_sock_wrapper *sock = NULL;
         | 
| 1555 | 
            +
                GetZmqSocket(obj);
         | 
| 1556 | 
            +
                return INT2NUM(zsocket_sndtimeo(sock->socket));
         | 
| 1557 | 
            +
            }
         | 
| 1558 | 
            +
             | 
| 1559 | 
            +
            /*
         | 
| 1560 | 
            +
             *  call-seq:
         | 
| 1561 | 
            +
             *     sock.sndtimeout = 200 =>  nil
         | 
| 1562 | 
            +
             *
         | 
| 1563 | 
            +
             *  Sets the socket SNDTIMEO value.
         | 
| 1564 | 
            +
             *
         | 
| 1565 | 
            +
             * === Examples
         | 
| 1566 | 
            +
             *     ctx = ZMQ::Context.new
         | 
| 1567 | 
            +
             *     sock = ctx.socket(:REP)
         | 
| 1568 | 
            +
             *     sock.sndtimeo = 200  =>  nil
         | 
| 1569 | 
            +
             *
         | 
| 1570 | 
            +
            */
         | 
| 1571 | 
            +
             | 
| 1572 | 
            +
            static VALUE rb_czmq_socket_set_opt_sndtimeo(VALUE obj, VALUE value)
         | 
| 1573 | 
            +
            {
         | 
| 1574 | 
            +
                zmq_sock_wrapper *sock = NULL;
         | 
| 1575 | 
            +
                ZmqSetSockOpt(obj, zsocket_set_sndtimeo, "SNDTIMEO", value);
         | 
| 1498 1576 | 
             
            }
         | 
| 1499 1577 |  | 
| 1500 1578 | 
             
            void _init_rb_czmq_socket()
         | 
| @@ -1567,4 +1645,8 @@ void _init_rb_czmq_socket() | |
| 1567 1645 | 
             
                rb_define_method(rb_cZmqSocket, "unsubscribe", rb_czmq_socket_set_opt_unsubscribe, 1);
         | 
| 1568 1646 | 
             
                rb_define_method(rb_cZmqSocket, "rcvmore?", rb_czmq_socket_opt_rcvmore, 0);
         | 
| 1569 1647 | 
             
                rb_define_method(rb_cZmqSocket, "events", rb_czmq_socket_opt_events, 0);
         | 
| 1648 | 
            +
                rb_define_method(rb_cZmqSocket, "rcvtimeo", rb_czmq_socket_opt_rcvtimeo, 0);
         | 
| 1649 | 
            +
                rb_define_method(rb_cZmqSocket, "rcvtimeo=", rb_czmq_socket_set_opt_rcvtimeo, 1);
         | 
| 1650 | 
            +
                rb_define_method(rb_cZmqSocket, "sndtimeo", rb_czmq_socket_opt_sndtimeo, 0);
         | 
| 1651 | 
            +
                rb_define_method(rb_cZmqSocket, "sndtimeo=", rb_czmq_socket_set_opt_sndtimeo, 1);
         | 
| 1570 1652 | 
             
            }
         | 
    
        data/ext/rbczmq/socket.h
    CHANGED
    
    | @@ -53,7 +53,7 @@ typedef struct { | |
| 53 53 | 
             
                  rb_raise(rb_eZmqError, "Cross thread violation for %s socket %p: created in thread %p, invoked on thread %p", zsocket_type_str((sock)->socket), (void *)(sock), (void *)(sock)->thread, (void *)rb_thread_current());
         | 
| 54 54 |  | 
| 55 55 | 
             
            #define ZmqAssertSockOptFor(sock_type) \
         | 
| 56 | 
            -
                if ( | 
| 56 | 
            +
                if (zsocket_type(sock->socket) != sock_type) \
         | 
| 57 57 | 
             
                    rb_raise(rb_eZmqError, "Socket option not supported on a %s socket!", zsocket_type_str(sock->socket));
         | 
| 58 58 |  | 
| 59 59 | 
             
            #define CheckBoolean(arg) \
         | 
    
        data/ext/rbczmq/timer.c
    CHANGED
    
    | @@ -1,7 +1,5 @@ | |
| 1 1 | 
             
            #include <rbczmq_ext.h>
         | 
| 2 2 |  | 
| 3 | 
            -
            static VALUE intern_call;
         | 
| 4 | 
            -
             | 
| 5 3 | 
             
            /*
         | 
| 6 4 | 
             
             * :nodoc:
         | 
| 7 5 | 
             
             *  GC mark callback
         | 
| @@ -99,8 +97,6 @@ static VALUE rb_czmq_timer_cancel(VALUE obj) | |
| 99 97 |  | 
| 100 98 | 
             
            void _init_rb_czmq_timer()
         | 
| 101 99 | 
             
            {
         | 
| 102 | 
            -
                intern_call = rb_intern("call");
         | 
| 103 | 
            -
             | 
| 104 100 | 
             
                rb_cZmqTimer = rb_define_class_under(rb_mZmq, "Timer", rb_cObject);
         | 
| 105 101 |  | 
| 106 102 | 
             
                rb_define_singleton_method(rb_cZmqTimer, "new", rb_czmq_timer_s_new, -1);
         | 
    
        data/ext/zeromq.tar.gz
    CHANGED
    
    | Binary file | 
    
        data/lib/zmq/loop.rb
    CHANGED
    
    | @@ -63,7 +63,6 @@ class ZMQ::Loop | |
| 63 63 | 
             
              def self.register_readable(pollable, handler = ZMQ::DefaultHandler, *args)
         | 
| 64 64 | 
             
                pollitem = ZMQ::Pollitem.new(pollable, ZMQ::POLLIN)
         | 
| 65 65 | 
             
                pollitem.handler = handler.new(pollitem, *args) if handler
         | 
| 66 | 
            -
                assert_handler_for_event(pollitem, :on_readable)
         | 
| 67 66 | 
             
                instance.register(pollitem)
         | 
| 68 67 | 
             
              end
         | 
| 69 68 |  | 
| @@ -76,7 +75,6 @@ class ZMQ::Loop | |
| 76 75 | 
             
              def self.register_writable(pollable, handler = ZMQ::DefaultHandler, *args)
         | 
| 77 76 | 
             
                pollitem = ZMQ::Pollitem.new(pollable, ZMQ::POLLOUT)
         | 
| 78 77 | 
             
                pollitem.handler = handler.new(pollitem, *args) if handler
         | 
| 79 | 
            -
                assert_handler_for_event(pollitem, :on_writable)
         | 
| 80 78 | 
             
                instance.register(pollitem)
         | 
| 81 79 | 
             
              end
         | 
| 82 80 |  | 
| @@ -119,13 +117,6 @@ class ZMQ::Loop | |
| 119 117 | 
             
                register_writable(socket, handler, args) if socket.poll_writable?
         | 
| 120 118 | 
             
                ret
         | 
| 121 119 | 
             
              end
         | 
| 122 | 
            -
             | 
| 123 | 
            -
              def self.assert_handler_for_event(pollitem, cb)
         | 
| 124 | 
            -
                unless pollitem.handler.respond_to?(cb)
         | 
| 125 | 
            -
                  pollitem.handler = nil
         | 
| 126 | 
            -
                  raise ZMQ::Error, "Pollable entity #{pollitem.pollable}'s handler #{pollitem.handler.class} expected to implement an #{cb} callback!"
         | 
| 127 | 
            -
                end
         | 
| 128 | 
            -
              end
         | 
| 129 120 | 
             
            end
         | 
| 130 121 |  | 
| 131 122 | 
             
            ZL = ZMQ::Loop
         | 
    
        data/lib/zmq/version.rb
    CHANGED
    
    
    
        data/test/test_context.rb
    CHANGED
    
    | @@ -49,7 +49,7 @@ class TestZmqContext < ZmqTestCase | |
| 49 49 | 
             
              def test_linger
         | 
| 50 50 | 
             
                ctx = ZMQ::Context.new
         | 
| 51 51 | 
             
                assert_raises TypeError do
         | 
| 52 | 
            -
                  ctx.linger = :invalid | 
| 52 | 
            +
                  ctx.linger = :invalid 
         | 
| 53 53 | 
             
                end
         | 
| 54 54 | 
             
                ctx.linger = 10
         | 
| 55 55 | 
             
                assert_raises ZMQ::Error do
         | 
| @@ -59,6 +59,20 @@ class TestZmqContext < ZmqTestCase | |
| 59 59 | 
             
                ctx.destroy
         | 
| 60 60 | 
             
              end
         | 
| 61 61 |  | 
| 62 | 
            +
              def test_hwm
         | 
| 63 | 
            +
                ctx = ZMQ::Context.new
         | 
| 64 | 
            +
                assert_raises TypeError do
         | 
| 65 | 
            +
                  ctx.hwm = :invalid
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
                ctx.hwm = 10
         | 
| 68 | 
            +
                assert_raises ZMQ::Error do
         | 
| 69 | 
            +
                  ctx.hwm = -2
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
                assert_equal 10, ctx.hwm
         | 
| 72 | 
            +
              ensure
         | 
| 73 | 
            +
                ctx.destroy
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
             | 
| 62 76 | 
             
              def test_bind_connect
         | 
| 63 77 | 
             
                ctx = ZMQ::Context.new
         | 
| 64 78 | 
             
                rep = ctx.bind(:REP, "inproc://test.bind_connect")
         | 
    
        data/test/test_pollitem.rb
    CHANGED
    
    | @@ -43,10 +43,20 @@ class TestZmqPollitem < ZmqTestCase | |
| 43 43 | 
             
                ctx.destroy
         | 
| 44 44 | 
             
              end
         | 
| 45 45 |  | 
| 46 | 
            +
              class TestHandler
         | 
| 47 | 
            +
                def initialize(*args); end
         | 
| 48 | 
            +
                def on_error(*args); end
         | 
| 49 | 
            +
                def on_readable(*args); end
         | 
| 50 | 
            +
                def on_writable(*args); end
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 46 53 | 
             
              def test_handler
         | 
| 47 54 | 
             
                pollitem = ZMQ::Pollitem.new(STDIN, ZMQ::POLLIN)
         | 
| 48 55 | 
             
                assert_nil pollitem.handler
         | 
| 49 | 
            -
                 | 
| 56 | 
            +
                assert_raises ZMQ::Error do
         | 
| 57 | 
            +
                  pollitem.handler = Module.new
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
                handler = TestHandler.new
         | 
| 50 60 | 
             
                pollitem.handler = handler
         | 
| 51 61 | 
             
                assert_equal handler, pollitem.handler
         | 
| 52 62 | 
             
              end
         | 
    
        data/test/test_socket.rb
    CHANGED
    
    | @@ -296,6 +296,25 @@ class TestZmqSocket < ZmqTestCase | |
| 296 296 | 
             
                ctx.destroy
         | 
| 297 297 | 
             
              end
         | 
| 298 298 |  | 
| 299 | 
            +
              def test_send_frame_dontwait
         | 
| 300 | 
            +
                ctx = ZMQ::Context.new
         | 
| 301 | 
            +
                rep = ctx.socket(:PAIR)
         | 
| 302 | 
            +
                rep.bind("inproc://test.socket-send_frame_dontwait")
         | 
| 303 | 
            +
                req = ctx.socket(:PAIR)
         | 
| 304 | 
            +
                req.connect("inproc://test.socket-send_frame_dontwait")
         | 
| 305 | 
            +
                5.times do |i|
         | 
| 306 | 
            +
                  frame = ZMQ::Frame("m#{i}")
         | 
| 307 | 
            +
                  req.send_frame(frame, ZMQ::Frame::DONTWAIT)
         | 
| 308 | 
            +
                end
         | 
| 309 | 
            +
                expected, frames = %w(m0 m1 m2 m3 m4), []
         | 
| 310 | 
            +
                5.times do
         | 
| 311 | 
            +
                  frames << rep.recv_frame.data
         | 
| 312 | 
            +
                end
         | 
| 313 | 
            +
                assert_equal expected, frames
         | 
| 314 | 
            +
              ensure
         | 
| 315 | 
            +
                ctx.destroy
         | 
| 316 | 
            +
              end
         | 
| 317 | 
            +
             | 
| 299 318 | 
             
              def test_send_receive_message
         | 
| 300 319 | 
             
                ctx = ZMQ::Context.new
         | 
| 301 320 | 
             
                rep = ctx.socket(:PAIR)
         | 
| @@ -381,6 +400,14 @@ class TestZmqSocket < ZmqTestCase | |
| 381 400 | 
             
                sock.reconnect_ivl_max = 5
         | 
| 382 401 | 
             
                assert_equal 5, sock.reconnect_ivl_max
         | 
| 383 402 |  | 
| 403 | 
            +
                assert_equal -1, sock.rcvtimeo
         | 
| 404 | 
            +
                sock.rcvtimeo = 200
         | 
| 405 | 
            +
                assert_equal 200, sock.rcvtimeo
         | 
| 406 | 
            +
             | 
| 407 | 
            +
                assert_equal -1, sock.sndtimeo
         | 
| 408 | 
            +
                sock.sndtimeo = 200
         | 
| 409 | 
            +
                assert_equal 200, sock.sndtimeo
         | 
| 410 | 
            +
             | 
| 384 411 | 
             
                sock.identity = "anonymous"
         | 
| 385 412 | 
             
                assert_raises ZMQ::Error do
         | 
| 386 413 | 
             
                  sock.identity = ""
         | 
    
        data/test/test_zmq.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,12 +1,12 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: rbczmq
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 4423076201732757652
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: "0. | 
| 8 | 
            +
              - 2
         | 
| 9 | 
            +
              version: "0.2"
         | 
| 10 10 | 
             
            platform: ruby
         | 
| 11 11 | 
             
            authors: 
         | 
| 12 12 | 
             
            - "Lourens Naud\xC3\xA9"
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2012- | 
| 18 | 
            +
            date: 2012-04-09 00:00:00 +01:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -26,7 +26,7 @@ dependencies: | |
| 26 26 | 
             
                requirements: 
         | 
| 27 27 | 
             
                - - ~>
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            -
                    hash:  | 
| 29 | 
            +
                    hash: 289844351982071926
         | 
| 30 30 | 
             
                    segments: 
         | 
| 31 31 | 
             
                    - 0
         | 
| 32 32 | 
             
                    - 8
         | 
| @@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 159 159 | 
             
              requirements: 
         | 
| 160 160 | 
             
              - - ">="
         | 
| 161 161 | 
             
                - !ruby/object:Gem::Version 
         | 
| 162 | 
            -
                  hash:  | 
| 162 | 
            +
                  hash: 2002549777813010636
         | 
| 163 163 | 
             
                  segments: 
         | 
| 164 164 | 
             
                  - 0
         | 
| 165 165 | 
             
                  version: "0"
         | 
| @@ -168,14 +168,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 168 168 | 
             
              requirements: 
         | 
| 169 169 | 
             
              - - ">="
         | 
| 170 170 | 
             
                - !ruby/object:Gem::Version 
         | 
| 171 | 
            -
                  hash:  | 
| 171 | 
            +
                  hash: 2002549777813010636
         | 
| 172 172 | 
             
                  segments: 
         | 
| 173 173 | 
             
                  - 0
         | 
| 174 174 | 
             
                  version: "0"
         | 
| 175 175 | 
             
            requirements: []
         | 
| 176 176 |  | 
| 177 177 | 
             
            rubyforge_project: 
         | 
| 178 | 
            -
            rubygems_version: 1. | 
| 178 | 
            +
            rubygems_version: 1.5.2
         | 
| 179 179 | 
             
            signing_key: 
         | 
| 180 180 | 
             
            specification_version: 3
         | 
| 181 181 | 
             
            summary: "Ruby extension for CZMQ - High-level C Binding for \xC3\x98MQ (http://czmq.zeromq.org)"
         |