Last chance! 50% off unlimited learning
Sale ends in
Encode or decode an ip_address
as a vector of raw bytes.
ip_to_bytes(x)bytes_to_ip(x)
For ip_to_bytes()
: An ip_address
vector
For bytes_to_ip()
: A blob::blob
vector
For ip_to_bytes()
: A blob::blob
vector
For bytes_to_ip()
: An ip_address
vector
The bytes are stored in network order (also known as big-endian order), which is part of the IP standard.
IPv4 addresses use 4 bytes, IPv6 addresses use 16 bytes,
and missing values are encoded as NULL
.
# NOT RUN {
x <- ip_address(c("192.168.0.1", "2001:db8::8a2e:370:7334", NA))
ip_to_bytes(x)
bytes_to_ip(ip_to_bytes(x))
# }
Run the code above in your browser using DataLab