module CZTop::ZsockOptions

This module adds the ability to access options of a {Socket} or an {Actor}.

@note Most socket options only take effect for subsequent bind/connects.

@see api.zeromq.org/4-1:zmq-setsockopt @see api.zeromq.org/4-1:zmq-getsockopt @see api.zeromq.org/czmq3-0:zsock-option

Public Instance Methods

fd() click to toggle source

Useful for registration in an event-loop. @return [Integer] @see OptionsAccessor#fd

# File lib/cztop/zsock_options.rb, line 41
def fd
  options.fd
end
options() click to toggle source

Access to the options of this socket. @return [OptionsAccessor] the memoized options accessor

# File lib/cztop/zsock_options.rb, line 17
def options
  @options ||= OptionsAccessor.new(self)
end
readable?() click to toggle source

Checks whether there’s a message that can be read from the socket without blocking. @return [Boolean] whether the socket is readable

# File lib/cztop/zsock_options.rb, line 25
def readable?
  (options.events & Poller::ZMQ::POLLIN).positive?
end
to_io() click to toggle source

@return [IO] IO for FD

# File lib/cztop/zsock_options.rb, line 47
def to_io
  IO.for_fd fd, autoclose: false
end
writable?() click to toggle source

Checks whether at least one message can be written to the socket without blocking. @return [Boolean] whether the socket is writable

# File lib/cztop/zsock_options.rb, line 33
def writable?
  (options.events & Poller::ZMQ::POLLOUT).positive?
end