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:



41
42
43
# File 'lib/cztop/zsock_options.rb', line 41

def fd
  options.fd
end

#optionsOptionsAccessor

Access to the options of this socket.

Returns:



17
18
19
# File 'lib/cztop/zsock_options.rb', line 17

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



25
26
27
# File 'lib/cztop/zsock_options.rb', line 25

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

#to_ioIO

Returns IO for FD.

Returns:

  • (IO)

    IO for FD



47
48
49
# File 'lib/cztop/zsock_options.rb', line 47

def to_io
  IO.for_fd fd, autoclose: false
end

#writable?Boolean

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

Returns:

  • (Boolean)

    whether the socket is writable



33
34
35
# File 'lib/cztop/zsock_options.rb', line 33

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