2 .\" $NetBSD: getaddrinfo.1,v 1.5 2014/04/22 06:02:06 wiz Exp $
4 .\" Copyright (c) 2013 The NetBSD Foundation, Inc.
5 .\" All rights reserved.
7 .\" This documentation is derived from text contributed to The NetBSD
8 .\" Foundation by Taylor R. Campbell.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
19 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 .\" POSSIBILITY OF SUCH DAMAGE.
36 .Nd resolve names to socket addresses
42 .Op Fl s Ar service Ns Op Ns / Ns Ar protocol
48 utility resolves host and service names to socket addresses with
50 and prints them to standard output in a user-friendly format.
52 The output is a sequence of lines with space-separated fields:
54 .Dl socket-type address-family protocol [af-specific data ...]
60 address families, the af-specific data are the IP/IPv6 address and port
63 Depending on the settings in
66 might query DNS for answers.
67 However, it is not intended to be a general-purpose DNS query utility.
72 These options are available:
75 Look up a canonical name as if with the
79 and print it on the first line before the socket addresses.
81 Specify an address family.
82 Address families are named like the
84 constants for address family numbers in the
86 header file but without the
94 Treat the service as numeric and do not attempt service name
95 resolution, as if with the
100 Treat the hostname as a numeric address and do not attempt name
101 resolution, as if with the
106 Return socket addresses intended for use with
112 By default, the socket addresses are intended for use with
119 Protocols are numeric or symbolic as listed in
121 .It Fl s Ar service Ns Op Ns / Ns Ar protocol
122 Specify a service to look up.
123 Services are symbolic or numeric with an optional
124 protocol suffix as listed in
126 If a service is not specified, a hostname is required.
128 Specify a socket type.
129 Socket types are named like the
131 constants for socket type numbers in the
133 header file but without the
135 prefix and lowercase.
146 .Bd -literal -offset indent
147 $ getaddrinfo www.NetBSD.org
148 dgram inet6 udp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0
149 dgram inet udp 149.20.53.67 0
150 stream inet6 tcp 2001:4f8:3:7:2e0:81ff:fe52:9ab6 0
151 stream inet tcp 149.20.53.67 0
154 The port number here is zero because no service was specified.
157 .Dq morden.NetBSD.org
158 for stream sockets on port 80, and show the canonical name:
159 .Bd -literal -offset indent
160 $ getaddrinfo -c -t stream -s 80 morden.NetBSD.org
161 canonname ftp.NetBSD.org
162 stream inet6 tcp 2001:470:1f05:3d::21 80
163 stream inet tcp 199.233.217.249 80
172 .Xr nsswitch.conf 5 ,
179 command first appeared in