Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Socket::Option#int
sockopt.int => integer
ext/socket/option.c
View on GitHub ↗
static VALUE
sockopt_int(VALUE self)
{
int i;
VALUE data = sockopt_data(self);
StringValue(data);
check_size(RSTRING_LEN(data), sizeof(int));
memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
return INT2NUM(i);
}
Returns the data in sockopt as an int.
The size and endian is dependent on the platform.
Example
sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.int => 1