Class: ZMQ::Socket

Inherits:
Object
  • Object
show all
Includes:
CommonSocketBehavior, IdentitySupport
Defined in:
lib/ffi-rzmq/socket.rb,
lib/ffi-rzmq/socket.rb

Instance Attribute Summary

Attributes included from CommonSocketBehavior

#name, #socket

Instance Method Summary collapse

Methods included from IdentitySupport

#identity, #identity=

Methods included from CommonSocketBehavior

#bind, #close, #connect, create, #initialize, #more_parts?, #recv_multipart, #recv_string, #recv_strings, #recvmsg, #recvmsgs, #send_and_close, #send_string, #send_strings, #sendmsg, #sendmsgs, #setsockopt

Instance Method Details

#disconnect(endpoint) ⇒ Object

Version3 only

Disconnect the socket from the given endpoint.



705
706
707
# File 'lib/ffi-rzmq/socket.rb', line 705

def disconnect(endpoint)
  LibZMQ.zmq_disconnect(endpoint)
end

#getsockopt(name, array) ⇒ Object

Get the options set on this socket.

name determines the socket option to request array should be an empty array; a result of the proper type (numeric, string, boolean) will be inserted into the first position.

Valid option_name values:

ZMQ::RCVMORE - true or false
ZMQ::HWM - integer
ZMQ::SWAP - integer
ZMQ::AFFINITY - bitmap in an integer
ZMQ::IDENTITY - string
ZMQ::RATE - integer
ZMQ::RECOVERY_IVL - integer
ZMQ::SNDBUF - integer
ZMQ::RCVBUF - integer
ZMQ::FD     - fd in an integer
ZMQ::EVENTS - bitmap integer
ZMQ::LINGER - integer measured in milliseconds
ZMQ::RECONNECT_IVL - integer measured in milliseconds
ZMQ::BACKLOG - integer
ZMQ::RECOVER_IVL_MSEC - integer measured in milliseconds
ZMQ::IPV4ONLY - integer

Returns 0 when the operation completed successfully. Returns -1 when this operation failed.

With a -1 return code, the user must check ZMQ.errno to determine the cause.

# retrieve high water mark
array = []
rc = socket.getsockopt(ZMQ::HWM, array)
hwm = array.first if ZMQ::Util.resultcode_ok?(rc)


596
597
598
599
600
601
602
603
604
605
# File 'lib/ffi-rzmq/socket.rb', line 596

def getsockopt name, array
  rc = __getsockopt__ name, array

  if Util.resultcode_ok?(rc) && (RCVMORE == name || MCAST_LOOP == name)
    # convert to boolean
    array[0] = 1 == array[0]
  end

  rc
end

#unbind(endpoint) ⇒ Object

Version3 only

Unbind the socket from the given endpoint.



713
714
715
# File 'lib/ffi-rzmq/socket.rb', line 713

def unbind(endpoint)
  LibZMQ.zmq_unbind(endpoint)
end