Next: Network Databases, Up: Networking
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 “1.0.0.0” 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 machine.
The address of the local host using the loopback device, ie. `127.0.0.1'.
Convert an IPv4 Internet address from printable string (dotted decimal notation) to an integer. E.g.,
(inet-aton "127.0.0.1") => 2130706433
Convert an IPv4 Internet address to a printable (dotted decimal notation) string. E.g.,
(inet-ntoa 2130706433) => "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
AF_INET
orAF_INET6
. E.g.,(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