Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.6.pdf
Скачиваний:
43
Добавлен:
23.08.2013
Размер:
2.64 Mб
Скачать

Miscellaneous Library Functions

9.5reshost.c

The reshost.c file implements only one function, in_reshost().

9.5.1in_reshost()

This function is used to resolve a host name into an IP address.

Syntax

int in_reshost(char *host, ip_addr *address, int flags)

where:

host

Contains the host-name string to be resolved.

address Points to the location where the resolved IP address is to be stored.

flags Are flags to control how in_reshost() operates (see Usage below).

Return value

Returns one of the following:

0

If successful.

ENP_Code If not successful (see ENP_ error codes on page A-2).

Usage

The in_reshost() function is called with a string containing the host name to be resolved, either in dotted-quad notation (for example, 192.168.117.43), or as a fully-qualified domain name (for example, myhost.mydomain.com). The in_reshost() function will attempt to parse the address, first as a dotted-quad address, and then using Domain Name System (DNS) lookup (if configured into the system), and will fill in the ip_addr pointed to by address with the IP address of the host. The flags value is used to control how the lookup is performed, and consists of the following flags, ORed together:

RH_VERBOSE Prints debugging/progress information about the request.

RH_BLOCK Blocks until the address has been resolved, or until an error has been detected.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

9-19

Miscellaneous Library Functions

IF RH_BLOCK is not specified, and DNS resolution is required, this routine returns immediately, having sent the request to the DNS server. It is important that the calling routine should zero the location pointed to by address before calling in_reshost(), and should then poll this function until the value pointed to by literal becomes nonzero.

Note

Trying to resolve a local hostname, such as ahost, without a qualifying domain name, will almost certainly fail. For domain-name resolution to be successful, the fully-qualified domain name is required.

9-20

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B