FREEBSD::ADDRINFO_UP(3)

NAME
freebsd::addrinfo_up - std::unique_ptr specialization for lists of socket addresses

LIBRARY
libutil++

SYNOPSIS
#include <libutil++.hh>
using addrinfo_up = std::unique_ptr<addrinfo, freeaddrinfo_deleter>;

DESCRIPTION
This class is a specialization of std::unique_ptr for socket addresses returned by getaddrinfo(3). When a list of socket addresses managed by an instance of this class is disposed, freeaddrinfo(3) is invoked to dispose of the list.

EXAMPLES

    freebsd::addrinfo_up
    resolve_address(const char *address, const char *port)
    {
    	struct addrinfo hints, *ai;
    	int error;
    	memset(&hints, 0, sizeof(hints));
    	hints.ai_family = AF_UNSPEC;
    	hints.ai_socktype = SOCK_STREAM;
    	error = getaddrinfo(address, port, &hints, &ai);
    	if (error != 0)
    		return {};
    	return freebsd::addrinfo_up(ai);
    }

SEE ALSO
getaddrinfo(3)