Module: CZTop::ZsockOptions

Included in:
Actor, Socket
Defined in:
lib/cztop/zsock_options.rb

Overview

Note:

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

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

Defined Under Namespace

Classes: OptionsAccessor

Instance Method Summary collapse

Instance Method Details

#fdInteger

Useful for registration in an event-loop.

Returns:

  • (Integer)

See Also:


35
36
37
# File 'lib/cztop/zsock_options.rb', line 35

def fd
  options.fd
end

#optionsOptionsAccessor

Access to the options of this socket.

Returns:


14
15
16
# File 'lib/cztop/zsock_options.rb', line 14

def options
  @options ||= OptionsAccessor.new(self)
end

#readable?Boolean

Checks whether there's a message that can be read from the socket without blocking.

Returns:

  • (Boolean)

    whether the socket is readable


21
22
23
# File 'lib/cztop/zsock_options.rb', line 21

def readable?
  (options.events & Poller::ZMQ::POLLIN) > 0
end

#writable?Boolean

Checks whether at least one message can be written to the socket without blocking.

Returns:

  • (Boolean)

    whether the socket is writable


28
29
30
# File 'lib/cztop/zsock_options.rb', line 28

def writable?
  (options.events & Poller::ZMQ::POLLOUT) > 0
end