Module: ZMQ::Util
- Included in:
- CommonSocketBehavior, Context, Message, Poller
- Defined in:
- lib/ffi-rzmq/util.rb
Overview
These methods don’t belong to any specific class. They get included in the #Context, #Socket and #Poller classes.
Class Method Summary collapse
-
.errno ⇒ Object
Returns the
errno
as set by the libzmq library. -
.error_string ⇒ Object
Returns a string corresponding to the currently set #errno.
- .nonblocking_flag ⇒ Object
-
.resultcode_ok?(rc) ⇒ Boolean
Returns true when
rc
is greater than or equal to 0, false otherwise. -
.version ⇒ Object
Returns an array of the form [major, minor, patch] to represent the version of libzmq.
Class Method Details
.errno ⇒ Object
Returns the errno
as set by the libzmq library.
21 22 23 |
# File 'lib/ffi-rzmq/util.rb', line 21 def self.errno LibZMQ.zmq_errno end |
.error_string ⇒ Object
Returns a string corresponding to the currently set #errno. These error strings are defined by libzmq.
28 29 30 |
# File 'lib/ffi-rzmq/util.rb', line 28 def self.error_string LibZMQ.zmq_strerror(errno).read_string end |
.nonblocking_flag ⇒ Object
50 51 52 |
# File 'lib/ffi-rzmq/util.rb', line 50 def self.nonblocking_flag NOBLOCK end |
.resultcode_ok?(rc) ⇒ Boolean
Returns true when rc
is greater than or equal to 0, false otherwise.
We use the >= test because zmq_poll() returns the number of sockets that had a read or write event triggered. So, a >= 0 result means it succeeded.
15 16 17 |
# File 'lib/ffi-rzmq/util.rb', line 15 def self.resultcode_ok? rc rc >= 0 end |
.version ⇒ Object
Returns an array of the form [major, minor, patch] to represent the version of libzmq.
Class method! Invoke as: ZMQ::Util.version
37 38 39 40 41 42 43 |
# File 'lib/ffi-rzmq/util.rb', line 37 def self.version major = FFI::MemoryPointer.new :int minor = FFI::MemoryPointer.new :int patch = FFI::MemoryPointer.new :int LibZMQ.zmq_version major, minor, patch [major.read_int, minor.read_int, patch.read_int] end |