File: gethostbyname.3

package info (click to toggle)
manpages-es 1.28-13
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,884 kB
  • ctags: 6
  • sloc: makefile: 63; sh: 55
file content (206 lines) | stat: -rw-r--r-- 7,172 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified Sat May 22 18:43:54 1993, David Metcalfe
.\" Modified Sun Jul 25 10:42:30 1993, Rik Faith (faith@cs.unc.edu)
.\" Modified Sun Feb 16 13:23:10 1997, Andries Brouwer (aeb@cwi.nl)
.\"
.\" Traducido al castellano (con permiso) por:
.\" Sebastian Desimone (chipy@argenet.com.ar) (desimone@fasta.edu.ar)
.\" Translation revised and fixed on Wed Apr 29 18:30:20 CEST 1998 by
.\"             Gerardo Aburruzaga Garca <gerardo.aburruzaga@uca.es>
.\" Translation revised Wed Dec 30 1998 by Juan Piernas <piernas@ditec.um.es>
.\" Modified Mon Dec 21 14:49:33 1998, Andries Brouwer (aeb@cwi.nl)
.\" Translation revised Sun Apr  4 1999 by Juan Piernas <piernas@ditec.um.es>
.\" Translation revised Tue Apr 18 2000 by Juan Piernas <piernas@ditec.um.es>
.\"
.TH GETHOSTBYNAME 3  "10 enero 1995" "BSD" "Manual del Programador de Linux"
.SH NOMBRE
gethostbyname, gethostbyaddr, sethostent, endhostent, herror, hstrerror \- obtienen una
entrada de anfitrin de red
.SH SINOPSIS
.nf
.B #include <netdb.h>
.B extern int h_errno;
.sp
.BI "struct hostent *gethostbyname(const char *" name );
.sp
.B #include <sys/socket.h> "        " /* para AF_INET */
.BI "struct hostent *gethostbyaddr(const char *" addr ", int " len ", int " type );
.sp
.BI "void sethostent(int " stayopen );
.sp
.B void endhostent(void);
.sp
.BI "void herror(const char *" s );
.sp
.BI "const char * hstrerror(int " err );
.fi
.SH DESCRIPCIN
La funcin \fBgethostbyname()\fP devuelve una estructura del tipo \fIhostent\fP
para el anfitrin (host) dado \fIname\fP. 
.\"El dominio corriente y sus ascendientes son
.\"buscados amenos que \fIname\fP termine con un punto. 
Aqu, \fIname\fP es ora un nombre de anfitrin, ora una direccin IPv4
en la notacin normal de puntos, ora una direccin IPv6 en la notacin
de dos puntos (y posiblemente de puntos). (Vea la RFC 1884 para una
descripcin de las direcciones en IPv6).
Si
.I name
es una direccin IPv4 o IPv6, no se realiza ninguna bsqueda y
.BR gethostbyname ()
simplemente copia
.I name
en el campo
.I h_name
y su equivalente
.I struct in_addr
en el campo
.I h_addr_list[0]
de la estructura
.I hostent
devuelta.
Si \fIname\fP no termina con un punto
y la variable de ambiente \fBHOSTALIASES\fP est
asignada, 
se buscar primero \fIname\fP en el 
fichero de alias sealado por \fBHOSTALIASES\fP.
(Vea
.BR hostname (7)
para saber cmo es el formato del fichero.)
Se buscan el dominio actual y sus ancestros a menos que \fIname\fP
termine en punto.
.PP
La funcin \fBgethostbyaddr()\fP devuelve una estructura del tipo \fIhostent\fP
para la direccin de anfitrin dada \fIaddr\fP de longitud \fIlen\fP y de tipo
\fItype\fP. El nico tipo de direccin vlido actualmente es AF_INET.
.PP
La funcin \fBsethostent()\fP especifica, si \fIstayopen\fP es true (1), 
que se debera emplear un conector (socket) TCP para las
interrogaciones al servidor de nombres y que la conexin debera
permanecer abierta durante sucesivas preguntas. De otro modo, las
peticiones al servidor de nombres utilizarn datagramas UDP.
.PP
La funcin \fBendhostent()\fP termina el uso de una conexin TCP para las 
peticiones al servidor de nombres.
.PP
La (obsoleta) funcin \fBherror()\fP muestra en stderr un mensaje de error
asociado con el valor actual de \fIh_errno\fP.
.PP
La (obsoleta) funcin \fBhstrerror()\fP toma un nmero de error
(habitualmente \fIh_errno\fP) y devuelve la cadena del mensaje correspondiente.
.PP
Las preguntas al servidor de nombres llevadas a cabo por \fBgethostbyname()\fP
y \fBgethostbyaddr()\fP usan una combinacin de uno o todos los servidores de
nombres \fBnamed\fP(8), una declaracin en \fI/etc/hosts\fP, y el
Servicio de Informacin de Red (NIS, antes Pginas Amarillas, YP),
dependiendo de los contenidos de la lnea 
\fIorder\fP en \fI/etc/host.conf\fP. (Vea 
.BR resolv+ (8)).
La accin predeterminada es preguntar a \fBnamed\fP(8), seguido por
\fI/etc/hosts\fP.
.PP
La estructura \fIhostent\fP se define en \fI<netdb.h>\fP como sigue:
.sp
.RS
.nf
.ne 7
.ta 8n 16n 32n
struct hostent {
	char	*h_name;		/* nombre oficial del anfitrin */
	char	**h_aliases;		/* lista de alias */
	int	h_addrtype;		/* tipo direccin anfitrin */
	int	h_length;		/* longitud de la direccin */
	char	**h_addr_list;		/* lista de direcciones */
}
#define h_addr	h_addr_list[0]		/* por compatibilidad atrs */
.ta
.fi
.RE
.PP
Los miembros de la estructura \fIhostent\fP son:
.TP
.I h_name
El nombre oficial de un anfitrin.
.TP
.I h_aliases
Una cadena terminada en el carcter nulo de los nombres alternativos
para el anfitrin. 
.TP
.I h_addrtype
El tipo de direccin; siempre AF_INET de momento.
.TP
.I h_length
La longitud de la direccin en bytes.
.TP
.I h_addr_list
Una cadena terminada en nulo de direcciones de red para el anfitrin
en orden de bytes de red.
.TP
.I h_addr
La primera direccin en \fIh_addr_list\fP por compatibilidad hacia atrs.
.SH "VALOR DEVUELTO"
Las funciones \fBgethostbyname()\fP y \fBgethostbyaddr()\fP devuelven la
estructura \fIhostent\fP, o un puntero NULL si ha ocurrido un error. En caso
de error, la variable \fIh_errno\fP contiene un nmero de error.
.SH "ERRORES"
La variable \fIh_errno\fP puede tener los siguientes valores:
.TP
.B HOST_NOT_FOUND
El anfitrin especificado es desconocido.
.TP
.BR NO_ADDRESS " o " NO_DATA
El nombre pedido es vlido pero no tiene una dirreccin IP.
.TP
.B NO_RECOVERY
Ha ocurrido un error no recuperable del servidor de nombres.
.TP
.B TRY_AGAIN
Ha ocurrido un error temporal sobre un servidor de nombres con
autoridad. Intente luego ms tarde.
.SH FICHEROS
.TP
.I /etc/host.conf
fichero de configuracin del resolvedor
.TP
.I /etc/hosts
fichero de base de datos de anfitriones
.fi
.SH "CONFORME A"
BSD 4.3.
SUS-v2 declara el parmetro
.I len
como del tipo
.IR size_t .
.SH RUMORES
La futura glibc2.2 seguir SUS-v2.
.SH "VASE TAMBIN"
.BR resolver (3),
.BR hosts (5),
.BR hostname (7),
.BR resolv+ (8),
.BR named (8)