Method: IPAddress::IPv6#data

Defined in:
lib/ipaddress/ipv6.rb

#dataObject

Returns the address portion of an IPv6 object in a network byte order format.

ip6 = IPAddress "2001:db8::8:800:200c:417a/64"

ip6.data
  #=> " \001\r\270\000\000\000\000\000\b\b\000 \fAz"

It is usually used to include an IP address in a data packet to be sent over a socket

a = Socket.open(params) # socket details here
ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
binary_data = ["Address: "].pack("a*") + ip.data

# Send binary data
a.puts binary_data


286
287
288
# File 'lib/ipaddress/ipv6.rb', line 286

def data
  @groups.pack("n8")
end