Class: XS::Socket

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

Overview

module IdentitySupport

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, #shutdown

Instance Method Details

#getsockopt(name, array) ⇒ Object

Get the options set on this socket.

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

Examples:

Retrieve send high water mark

array = []
rc = socket.getsockopt(XS::SNDHWM, array)
sndhwm = array.first if XS::Util.resultcode_ok?(rc)

Parameters:

  • name

    One of XS::RCVMORE, XS::SNDHWM, XS::AFFINITY, XS::IDENTITY, XS::RATE, XS::RECOVERY_IVL, XS::SNDBUF, XS::RCVBUF, XS::FD, XS::EVENTS, XS::LINGER, XS::RECONNECT_IVL, XS::BACKLOG, XS::RECONNECT_IVL_MAX@, XS::RCVTIMEO, XS::SNDTIMEO, XS::IPV4ONLY, XS::TYPE, XS::RCVHWM, XS::MAXMSGSIZE, XS::MULTICAST_HOPS, XS::KEEPALIVE

  • array

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

Returns:

  • 0 when the operation completed successfully

  • -1 when this operation failed



657
658
659
660
661
662
663
664
665
666
# File 'lib/ffi-rxs/socket.rb', line 657

def getsockopt name, array
  rc = __getsockopt__ name, array

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

  rc
end