📄 gethostent.3n
字号:
.TH gethostent 3n.SH Namegethostent, gethostbyaddr, gethostbyname, sethostent, endhostent \- get hosts entry.SH Syntax.B "#include <netdb.h>.PP.B "struct hostent *gethostent().PP.B "struct hostent *gethostbyname(\fIname\fP).br.B "char *\fIname\fP;.PP.B "struct hostent *gethostbyaddr(\fIaddr\fP, \fIlen\fP, \fItype\fP).br.B "char *\fIaddr\fP; int \fIlen\fP, \fItype\fP;.PP.B void sethostent(\fIstayopen\fP).br.B int \fIstayopen\fP;.PP.B "void endhostent().NXR "gethostent subroutine".NXR "gethostent subroutine" "svc.conf file and".SH Description.NXR "gethostent subroutine".NXR "gethostbyaddr subroutine".NXR "gethostbyname subroutine".NXR "sethostent subroutine".NXR "endhostent subroutine".NXR "hosts file" "getting entry"The.PN gethostent ,.PN gethostbyname ,and.PN gethostbyaddrsubroutines return a pointer to an object with thefollowing structurecontaining the broken-out fieldsreflecting information obtained from the.PN hostsdatabase..EX 0struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */#define h_addr h_addr_list[0] /* address for backward compatibility */};.EE.PPThe members of this structure are:.TP \w'h_addrtype'u+2nh_nameOfficial name of the host..TP \w'h_addrtype'u+2nh_aliasesA zero terminated array of alternate names for the host..TP \w'h_addrtype'u+2nh_addrtypeThe type of address being returned; currently always AF_INET..TP \w'h_addrtype'u+2nh_lengthThe length, in bytes, of the address..TP \w'h_addrtype'u+2nh_addrA pointer to the network address for the host.Host addresses are returnedin network byte order..PPIf the .I stayopenflag on a .PN sethostentsubroutine is NULL, thehosts database is opened. Otherwise the.PN sethostenthas the effect of rewinding the .PN hostsdatabase.The.PN endhostentmay be called toclose the.PN hosts database when processing is complete..PPThe.PN gethostentsubroutine simply reads the nextline while.PN gethostbynameand.PN gethostbyaddrsearch until a matching.I name,or.I addr,.I len,.I typeis found(or until EOF is encountered).The.PN gethostentsubroutine keeps a pointer in the database, allowingsuccessive calls to be used to search the entire file..PPThe.PN gethostbynameand.PN gethostbyaddrsubroutines query the .PN hosts database..PPA call to.PN sethostentmust be made before a.PN whileloop using.PN gethostentin order to perform initialization and an.PN endhostentmust be used after the loop. Both.PN gethostbynameand.PN gethostbyaddrmake calls to.PN sethostentand.PN endhostent ..SH Restrictions.NXR "gethostent subroutine" "restrictions"All informationis contained in a static areaso it must be copied if it isto be saved. Only the Internetaddress format is currently understood..PPIf YP is running, .PN gethostentdoes not return the entries in any particular order.See the .I Guide to the Yellow Pages Servicefor setup information..PPThe .PN hostsdatabase may also be distributed via the BIND/Hesiodnaming service. See the.I Guide to the BIND/Hesiod Servicefor more information..SH Return ValuesNull pointer(0) returned on EOF or error..SH Files.PN /etc/hosts.SH See Alsohosts(5), svc.conf(5).br.I Guide to the BIND/Hesiod Service.br.I Guide to the Yellow Pages Service
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -