README
POSIX::getaddrinfo
The POSIX getaddrinfo() function resolves host names into IP addresses & canonical names, among other things.
Short tutorial on calling a C function demonstrates the creation of an interface to this standard library function using NativeCall.
This module extends that idea by adding raku-friendly interfaces.
Synopsis
Get-Addr-Info()
use POSIX::getaddrinfo :Get-Addr-Info;
Get-Addr-Info('localhost');
# [6] @0
# ā 0 = .POSIX::getaddrinfo::Get-Addr-Info-Record @1
# ā ā $.cannonname = localhost.Str
# ā ā $.family = AF_INET6.Str
# ā ā $.socktype = SOCK_STREAM.Str
# ā ā $.address = ::1.Str
# ā 1 = .POSIX::getaddrinfo::Get-Addr-Info-Record @2
# ā ā $.cannonname = localhost.Str
# ā ā $.family = AF_INET6.Str
# ā ā $.socktype = SOCK_DGRAM.Str
# ā ā $.address = ::1.Str
# ā 2 = .POSIX::getaddrinfo::Get-Addr-Info-Record @3
# ā ā $.cannonname = localhost.Str
# ā ā $.family = AF_INET6.Str
# ā ā $.socktype = SOCK_RAW.Str
# ā ā $.address = ::1.Str
# ā 3 = .POSIX::getaddrinfo::Get-Addr-Info-Record @4
# ā ā $.cannonname = localhost.Str
# ā ā $.family = AF_INET.Str
# ā ā $.socktype = SOCK_STREAM.Str
# ā ā $.address = 127.0.0.1.Str
# ā 4 = .POSIX::getaddrinfo::Get-Addr-Info-Record @5
# ā ā $.cannonname = localhost.Str
# ā ā $.family = AF_INET.Str
# ā ā $.socktype = SOCK_DGRAM.Str
# ā ā $.address = 127.0.0.1.Str
# ā 5 = .POSIX::getaddrinfo::Get-Addr-Info-Record @6
# ā $.cannonname = localhost.Str
# ā $.family = AF_INET.Str
# ā $.socktype = SOCK_RAW.Str
# ā $.address = 127.0.0.1.Str
Get-Addr-Info-IPV4-STREAM()
use POSIX::getaddrinfo :Get-Addr-Info-IPV4-STREAM;
Get-Addr-Info-IPV4-STREAM('services');
# [1] @0
# ā 0 = .POSIX::getaddrinfo::Get-Addr-Info-Record @1
# ā $.cannonname = services.Str
# ā $.family = AF_INET.Str
# ā $.socktype = SOCK_STREAM.Str
# ā $.address = 192.168.1.159.Str
Get-Addr-Info-IPV4-STREAM-IPAddrs()
use POSIX::getaddrinfo :Get-Addr-Info-IPV4-STREAM-IPAddrs;
Get-Addr-Info-IPV4-STREAM-IPAddrs('services');
# 1] @0
# ā 0 = 192.168.1.159.Str
Get-Addr-Info-IPV4-STREAM-Names()
use POSIX::getaddrinfo :Get-Addr-Info-IPV4-STREAM-Names;
Get-Addr-Info-IPV4-STREAM-Names('myserver'); # DNS serving 'mydomain.com'
# 1] @0
# ā 0 = myserver.mydomain.com.Str
Limitations
Only on Linux, so far.
Citation
Taken almost verbatim (and augmented) from raku.org documentation, Short tutorial on calling a C function.
AUTHOR
Mark Devine [email protected]