This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# BasicSocket.getsockopt (from ruby core) --- getsockopt(level, optname) => socketoption --- Gets a socket option. These are protocol and system specific, see your local system documentation for details. The option is returned as a Socket::Option object. ### Parameters * `level` is an integer, usually one of the SOL_ constants such as Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, possibly without prefix, is also accepted. * `optname` is an integer, usually one of the SO_ constants, such as Socket::SO_REUSEADDR. A string or symbol of the name, possibly without prefix, is also accepted. ### Examples Some socket options are integers with boolean values, in this case #getsockopt could be called like this: reuseaddr = sock.getsockopt(:SOCKET, :REUSEADDR).bool optval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR) optval = optval.unpack "i" reuseaddr = optval[0] == 0 ? false : true Some socket options are integers with numeric values, in this case #getsockopt could be called like this: ipttl = sock.getsockopt(:IP, :TTL).int optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) ipttl = optval.unpack1("i") Option values may be structs. Decoding them can be complex as it involves examining your system headers to determine the correct definition. An example is a +struct linger+, which may be defined in your system headers as: struct linger { int l_onoff; int l_linger; }; In this case #getsockopt could be called like this: # Socket::Option knows linger structure. onoff, linger = sock.getsockopt(:SOCKET, :LINGER).linger optval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER) onoff, linger = optval.unpack "ii" onoff = onoff == 0 ? false : true
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.