Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Socket::AncillaryData#int
ancillarydata.int => integer
ext/socket/ancdata.c
View on GitHub ↗
static VALUE
ancillary_int(VALUE self)
{
VALUE data;
int i;
data = ancillary_data(self);
if (RSTRING_LEN(data) != sizeof(int))
rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld", (int)sizeof(int), (long)RSTRING_LEN(data));
memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
return INT2NUM(i);
}
Returns the data in ancillarydata as an int.
The size and endian is dependent on the host.
Example
ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) p ancdata.int #=> 2