282 If the flag bit \fBNI_NUMERICSERV\fR is set, the numeric form of the service
283 address is returned (for example, its port number) instead of its name. The two
284 \fBNI_NUMERIC\fR* flags are required to support the \fB-n\fR flag that many
285 commands provide.
286 .sp
287 .LP
288 A fifth flag bit, \fBNI_DGRAM\fR, specifies that the service is a datagram
289 service, and causes \fBgetservbyport\fR(3SOCKET) to be called with a second
290 argument of \fBudp\fR instead of the default \fBtcp\fR. This is required for
291 the few ports (for example, 512-514) that have different services for UDP and
292 TCP.
293 .sp
294 .LP
295 These \fBNI_\fR* flags are defined in <\fBnetdb.h\fR> along with the \fBAI_\fR*
296 flags already defined for \fBgetaddrinfo()\fR.
297 .SH RETURN VALUES
298 .sp
299 .LP
300 For \fBgetaddrinfo()\fR, if the query is successful, a pointer to a linked list
301 of one or more \fBaddrinfo\fR structures is returned by the fourth argument and
302 the function returns \fB0\fR. The order of the addresses returned i nthe fourth
303 argument is discussed in the ADDRESS ORDERING section. If the query fails, a
304 non-zero error code will be returned. For \fBgetnameinfo()\fR, if successful,
305 the strings hostname and service are copied into \fIhost\fR and \fIserv\fR,
306 respectively. If unsuccessful, zero values for either \fIhostlen\fR or
307 \fIservlen\fR will suppress the associated lookup; in this case no data is
308 copied into the applicable buffer. If \fBgai_strerror()\fR is successful, a
309 pointer to a string containing an error message appropriate for the \fBEAI_\fR*
310 errors is returned. If \fIerrcode\fR is not one of the \fBEAI_\fR* values, a
311 pointer to a string indicating an unknown error is returned.
312 .SS "Address Ordering"
313 .sp
314 .LP
315 AF_INET6 addresses returned by the fourth argument of \fBgetaddrinfo()\fR are
316 ordered according to the algorithm described in \fIRFC 3484, Default Address
317 Selection for Internet Protocol version 6 (IPv6)\fR. The addresses are ordered
318 using a list of pair-wise comparison rules which are applied in order. If a
319 rule determines that one address is better than another, the remaining rules
320 are irrelevant to the comparison of those two addresses. If two addresses are
321 equivalent according to one rule, the remaining rules act as a tie-breaker. The
322 address ordering list of pair-wise comparison rules follow below:
|
282 If the flag bit \fBNI_NUMERICSERV\fR is set, the numeric form of the service
283 address is returned (for example, its port number) instead of its name. The two
284 \fBNI_NUMERIC\fR* flags are required to support the \fB-n\fR flag that many
285 commands provide.
286 .sp
287 .LP
288 A fifth flag bit, \fBNI_DGRAM\fR, specifies that the service is a datagram
289 service, and causes \fBgetservbyport\fR(3SOCKET) to be called with a second
290 argument of \fBudp\fR instead of the default \fBtcp\fR. This is required for
291 the few ports (for example, 512-514) that have different services for UDP and
292 TCP.
293 .sp
294 .LP
295 These \fBNI_\fR* flags are defined in <\fBnetdb.h\fR> along with the \fBAI_\fR*
296 flags already defined for \fBgetaddrinfo()\fR.
297 .SH RETURN VALUES
298 .sp
299 .LP
300 For \fBgetaddrinfo()\fR, if the query is successful, a pointer to a linked list
301 of one or more \fBaddrinfo\fR structures is returned by the fourth argument and
302 the function returns \fB0\fR. The order of the addresses returned in the fourth
303 argument is discussed in the ADDRESS ORDERING section. If the query fails, a
304 non-zero error code will be returned. For \fBgetnameinfo()\fR, if successful,
305 the strings hostname and service are copied into \fIhost\fR and \fIserv\fR,
306 respectively. If unsuccessful, zero values for either \fIhostlen\fR or
307 \fIservlen\fR will suppress the associated lookup; in this case no data is
308 copied into the applicable buffer. If \fBgai_strerror()\fR is successful, a
309 pointer to a string containing an error message appropriate for the \fBEAI_\fR*
310 errors is returned. If \fIerrcode\fR is not one of the \fBEAI_\fR* values, a
311 pointer to a string indicating an unknown error is returned.
312 .SS "Address Ordering"
313 .sp
314 .LP
315 AF_INET6 addresses returned by the fourth argument of \fBgetaddrinfo()\fR are
316 ordered according to the algorithm described in \fIRFC 3484, Default Address
317 Selection for Internet Protocol version 6 (IPv6)\fR. The addresses are ordered
318 using a list of pair-wise comparison rules which are applied in order. If a
319 rule determines that one address is better than another, the remaining rules
320 are irrelevant to the comparison of those two addresses. If two addresses are
321 equivalent according to one rule, the remaining rules act as a tie-breaker. The
322 address ordering list of pair-wise comparison rules follow below:
|