lib/ffi-rzmq/socket.rb in ffi-rzmq-0.5.0 vs lib/ffi-rzmq/socket.rb in ffi-rzmq-0.5.1

- old
+ new

@@ -17,11 +17,11 @@ # By default, this class uses ZMQ::Message for regular Ruby # memory management. # # +type+ can be one of ZMQ::REQ, ZMQ::REP, ZMQ::PUB, - # ZMQ::SUB, ZMQ::PAIR, ZMQ::UPSTREAM, ZMQ::DOWNSTREAM, + # ZMQ::SUB, ZMQ::PAIR, ZMQ::PULL, ZMQ::PUSH, # ZMQ::XREQ or ZMQ::XREP. # # Can raise two kinds of exceptions depending on the error. # ContextError:: Raised when a socket operation is attempted on a terminated # #Context. See #ContextError. @@ -38,11 +38,11 @@ error_check ZMQ_SOCKET_STR, @socket.null? ? 1 : 0 else raise ContextError.new ZMQ_SOCKET_STR, 0, ETERM, "Context pointer was null" end - define_finalizer + #define_finalizer end # Set the queue options on this socket. # # Valid +option_name+ values that take a numeric +option_value+ are: @@ -117,45 +117,45 @@ IDENTITY, SNDBUF, RCVBUF].include? option_name # we didn't understand the passed option argument # will force a raise error_check ZMQ_SETSOCKOPT_STR, -1 end - + option_value, option_length = alloc_temp_sockopt_buffers option_name result_code = LibZMQ.zmq_getsockopt @socket, option_name, option_value, option_length error_check ZMQ_GETSOCKOPT_STR, result_code ret = 0 - + case option_name when RCVMORE, MCAST_LOOP # boolean return ret = option_value.read_long_long != 0 when HWM, SWAP, AFFINITY, RATE, RECOVERY_IVL, SNDBUF, RCVBUF ret = option_value.read_long_long when IDENTITY ret = option_value.read_string(option_length.read_long_long) end - + ret end end - + # Convenience method for checking on additional message parts. # # Equivalent to Socket#getsockopt ZMQ::RCVMORE # def more_parts? getsockopt ZMQ::RCVMORE end - + # Convenience method for getting the value of the socket IDENTITY. # def identity getsockopt ZMQ::IDENTITY end - + # Convenience method for setting the value of the socket IDENTITY. # def identity= value setsockopt ZMQ::IDENTITY, value.to_s end @@ -310,10 +310,10 @@ def _recv message, flags = 0 result_code = LibZMQ.zmq_recv @socket, message.address, flags flags != NOBLOCK ? error_check(ZMQ_RECV_STR, result_code) : error_check_nonblock(result_code) end - + def alloc_temp_sockopt_buffers option_name length = FFI::MemoryPointer.new :int64 case option_name when RCVMORE, MCAST_LOOP, HWM, SWAP, AFFINITY, RATE, RECOVERY_IVL, SNDBUF, RCVBUF