Name resolution v0.1.0

Source
getaddrinfo and the list of addresses it returns.

AddressInfo

pub struct AddressInfo {
    pub flags: int32;
    pub family: int32;
    pub socketType: int32;
    pub protocol: int32;
    pub addressLength: uint32;
    pub address: *opaque;
    pub canonicalName: *char8;
    pub next: *var AddressInfo;
}

The C library's addrinfo: one result of getaddrinfo, linked to the next.

Source

Fields

NameTypeDescription
flagsint32Flags such as AI_PASSIVE.
familyint32The address family, or zero for any.
socketTypeint32The socket type, or zero for any.
protocolint32The protocol, or zero for any.
addressLengthuint32The size of address in bytes.
address*opaqueThe address, a sockaddr.
canonicalName*char8The host's canonical name, or null.
next*var AddressInfoThe next result, or null after the last.

getaddrinfo

pub extern func getaddrinfo(
    node: *char8,
    service: *char8,
    hints: *AddressInfo,
    result: *var *var AddressInfo
) -> int32

Looks up the addresses of a host and service.

See also: https://man7.org/linux/man-pages/man3/getaddrinfo.3.html

Source

Parameters

NameTypeDescription
node*char8the host name or numeric address, NUL-terminated, or null
service*char8the service name or port number, NUL-terminated, or null
hints*AddressInfowhat kind of results are wanted, or null for every kind
result*var *var AddressInforeceives the first result, freed with freeaddrinfo

Returns: zero, or an EAI_* code

freeaddrinfo

pub extern func freeaddrinfo(info: *var AddressInfo)

Frees the results of getaddrinfo.

See also: https://man7.org/linux/man-pages/man3/freeaddrinfo.3.html

Source

Parameters

NameTypeDescription
info*var AddressInfothe first result