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]

POSIX::getaddrinfo v0.2.0

POSIX getaddrinfo with added interfaces

Authors

  • Mark Devine

License

Artistic 2.0

Dependencies

Test Dependencies

Provides

  • POSIX::getaddrinfo
  • POSIX::getaddrinfo::Constants

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.