getservent.3n
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 3N 代码 · 共 157 行
3N
157 行
.\" SCCSID: @(#)getservent.3n 8.2 1/29/91.TH getservent 3n.SH Namegetservent, getservbyname, getservbyport, setservent, endservent \- get services entry.SH Syntax.nf.B #include <netdb.h>.PP.B struct servent *getservent().PP.B struct servent *getservbyname\fI(name, proto)\fP.B char *\fIname\fP, *\fIproto\fP;.PP.B struct servent *getservbyport\fI(port, proto)\fP.B int \fIport\fP; char *\fIproto\fP;.PP.B void setservent\fI(stayopen)\fP.B int \fIstayopen\fP.PP.B void endservent().fi.SH Description.NXR "getservent subroutine".NXR "getservbyport subroutine".NXR "getservbyname subroutine".NXR "setservent subroutine".NXR "endservent subroutine".NXR "services file" "getting entry"The.PN getservent ,.PN getservbyname ,and.PN getservbyportsubroutines each return a pointer to an object with thefollowing structurecontaining the broken-outfields of a line in the network .PN services database..EX.nfstruct servent { char *s_name; /* official name of service */ char **s_aliases; /* alias list */ long s_port; /* port service resides at */ char *s_proto; /* protocol to use */};.fi.EE.PPThe members of this structure are:.TP \w's_aliases'u+2ns_nameThe official name of the service..TP \w's_aliases'u+2ns_aliasesA zero terminated list of alternate names for the service..TP \w's_aliases'u+2ns_portThe port number at which the service resides.Port numbers are returned in network byte order..TP \w's_aliases'u+2ns_protoThe name of the protocol to use when contacting theservice..PPIf the .I stayopenflag on a .PN setserventsubroutine is NULL, the.PN services database is opened. Otherwise, the.PN setserventhas the effect of rewinding the .PN services database.The.PN endserventsubroutine may be called to close the .PN services database when processing is complete..PPThe.PN getserventsubroutine reads the nextline; .PN getservbynameand.PN getservbyportsearch until a matching.I nameor.I portis found(or until EOF is encountered).The.PN getserventsubroutine keeps a pointer in the database, allowingsuccessive calls to be used to search the entire file.If a non-NULL protocol name,.PN proto ,is also supplied, searches must also match the protocol..PPThe.PN setserventroutine must be called before a.PN whileloop that uses.PN getserventin order to initialize variables in the.PN setserventroutine and an.PN endserventmust be used after the loop. Both.PN getservbyportand.PN getservbynamemake calls to.PN setserventand.PN endservent ..SH Restrictions.NXR "getservent subroutine" "restrictions"All informationis contained in a static areaso it must be copied if it isto be saved..PPIf the Yellow Pages Service is running, .PN getserventdoes not return the entries in any particular order.See the .I Guide to the Yellow Pages Servicefor setup information..PPThe .PN services database can also be distributed by 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/services.SH See Alsoservices(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 + =
减小字号Ctrl + -
显示快捷键?