Class: XS::Socket
- Inherits:
-
Object
- Object
- XS::Socket
- Includes:
- CommonSocketBehavior, IdentitySupport
- Defined in:
- lib/ffi-rxs/socket.rb
Overview
module IdentitySupport
Instance Attribute Summary
Attributes included from CommonSocketBehavior
Instance Method Summary collapse
-
#getsockopt(name, array) ⇒ Object
Get the options set on this socket.
Methods included from IdentitySupport
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
Methods included from Util
bind_to_random_tcp_port, errno, error_string, resultcode_ok?, version
Instance Method Details
#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:
XS::RCVMORE - true or false
XS::HWM - integer
XS::SWAP - integer
XS::AFFINITY - bitmap in an integer
XS::IDENTITY - string
XS::RATE - integer
XS::RECOVERY_IVL - integer
XS::SNDBUF - integer
XS::RCVBUF - integer
XS::FD - fd in an integer
XS::EVENTS - bitmap integer
XS::LINGER - integer measured in milliseconds
XS::RECONNECT_IVL - integer measured in milliseconds
XS::BACKLOG - integer
XS::RECOVER_IVL_MSEC - integer measured in milliseconds
Returns 0 when the operation completed successfully. Returns -1 when this operation failed.
With a -1 return code, the user must check XS.errno to determine the cause.
# retrieve high water mark
array = []
rc = socket.getsockopt(XS::HWM, array)
hwm = array.first if XS::Util.resultcode_ok?(rc)
603 604 605 606 607 608 609 610 611 612 |
# File 'lib/ffi-rxs/socket.rb', line 603 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 |