This section describes procedures which convert internet addresses between numeric and string formats.
An IPv4 Internet address is a 4-byte value, represented in Guile as an integer in host byte order, so that say “0.0.0.1” is 1, or “188.8.131.52” is 16777216.
Some underlying C functions use network byte order for addresses, Guile converts as necessary so that at the Scheme level its host byte order everywhere.
For a server, this can be used with
bind (see Network Sockets and Communication) to allow connections from any interface on
The broadcast address on the local network.
The address of the local host using the loopback device, ie. ‘127.0.0.1’.
Return the network number part of the given IPv4 Internet address. E.g.,
(inet-netof 2130706433) ⇒ 127
Return the local-address-with-network part of the given IPv4 Internet address, using the obsolete class A/B/C system. E.g.,
(inet-lnaof 2130706433) ⇒ 1
Make an IPv4 Internet address by combining the network number net with the local-address-within-network number lna. E.g.,
(inet-makeaddr 127 1) ⇒ 2130706433
An IPv6 Internet address is a 16-byte value, represented in Guile as an integer in host byte order, so that say “::1” is 1.
Convert a network address from an integer to a printable string.
family can be
(inet-ntop AF_INET 2130706433) ⇒ "127.0.0.1" (inet-ntop AF_INET6 (- (expt 2 128) 1)) ⇒ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
Convert a string containing a printable network address to an integer
address. family can be
(inet-pton AF_INET "127.0.0.1") ⇒ 2130706433 (inet-pton AF_INET6 "::1") ⇒ 1