Previous: , Up: posix socket addresses   [Index]


4.15.1.5 Host address informations

Structure Type: struct-addrinfo

Scheme level representation of struct addrinfo. It has the following fields:

ai_flags

Fixnum.

ai_family

Fixnum, specifies the Internet address family; AF_INET, AF_INET6 of AF_UNSPEC.

ai_socktype

Fixnum, specifies the socket type; SOCK_STREAM, SOCK_DGRAM or other SOCK_ value.

ai_protocol

Fixnum, specifies the protocol of the socket address.

ai_addrlen

Fixnum, the number of bytes in the bytevector referenced by ai_addr.

ai_addr

Bytevector, holds an instance of struct sockaddr of ai_addrlen bytes.

ai_canonname

False or bytevector, represents the canoncal name of the host when available.

Function: make-struct-addrinfo flags family socktype protocol addrlen addr canonname

Build and return an instance of struct-addrinfo.

Function: struct-addrinfo? obj

Return true if obj is an instance of struct-addrinfo.

Function: struct-addrinfo-ai_flags addrinfo
Function: struct-addrinfo-ai_family addrinfo
Function: struct-addrinfo-ai_socktype addrinfo
Function: struct-addrinfo-ai_protocol addrinfo
Function: struct-addrinfo-ai_addrlen addrinfo
Function: struct-addrinfo-ai_addr addrinfo
Function: struct-addrinfo-ai_canonname addrinfo

Accessors for the fields of struct-addrinfo.

Function: getaddrinfo node service
Function: getaddrinfo node service hints

Interface to the C function getaddrinfo(), see the manual page getaddrinfo(3). Given the strings or bytevectors node and service identifying an Internet host and a service, build a list of struct-addrinfo instances representing addresses to which sockets can be bound or connected.

Both node and service can be false, in which case the corresponding arguments handed to the C function are NULL. The optional argument hints must be #f or an instance of struct-addrinfo used to select matching hosts.

If successful: return the list of data structures, else raise an exception.

(px.getaddrinfo "github.com" "smtp")
⇒ (#["struct-addrinfo"
        ai_flags=40             ai_family=AF_INET
        ai_socktype=SOCK_DGRAM  ai_protocol=17
        ai_addrlen=16
        ai_addr=#vu8(2 0 0 25 207 97 227 239 0 0 0 0 0 0 0 0)
        ai_canonname=#f]
    #["struct-addrinfo"
        ai_flags=40             ai_family=AF_INET
        ai_socktype=SOCK_STREAM ai_protocol=6
        ai_addrlen=16
        ai_addr=#vu8(2 0 0 25 207 97 227 239 0 0 0 0 0 0 0 0)
        ai_canonname=#f])

Previous: , Up: posix socket addresses   [Index]