1.\" 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 2025 Chelsio Communications, Inc. 5.\" Written by: John Baldwin <jhb@FreeBSD.org> 6.\" 7.Dd July 31, 2025 8.Dt FREEBSD::ADDRINFO_UP 3 9.Os 10.Sh NAME 11.Nm freebsd::addrinfo_up 12.Nd std::unique_ptr specialization for lists of socket addresses 13.Sh LIBRARY 14.Lb libutil++ 15.Sh SYNOPSIS 16.In libutil++.hh 17.Ft using addrinfo_up = std::unique_ptr<addrinfo, freeaddrinfo_deleter>; 18.Sh DESCRIPTION 19This class is a specialization of 20.Vt std::unique_ptr 21for socket addresses returned by 22.Xr getaddrinfo 3 . 23When a list of socket addresses managed by an instance of this class is 24disposed, 25.Xr freeaddrinfo 3 26is invoked to dispose of the list. 27.Sh EXAMPLES 28.Bd -literal -offset indent 29freebsd::addrinfo_up 30resolve_address(const char *address, const char *port) 31{ 32 struct addrinfo hints, *ai; 33 int error; 34 35 memset(&hints, 0, sizeof(hints)); 36 hints.ai_family = AF_UNSPEC; 37 hints.ai_socktype = SOCK_STREAM; 38 error = getaddrinfo(address, port, &hints, &ai); 39 if (error != 0) 40 return {}; 41 return freebsd::addrinfo_up(ai); 42} 43.Ed 44.Sh SEE ALSO 45.Xr getaddrinfo 3 46