*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> getservent (3)              



NAME    [Toc]    [Back]

       getservent,  getservent_r - Get a services file entry from
       the /etc/services file.

SYNOPSIS    [Toc]    [Back]

       #include <netdb.h>

       struct servent *getservent(
               void );

       [Tru64 UNIX]  The following obsolete function is supported
       only  for  backward  compatibility reasons. You should not
       use it in new designs.  int getservent_r(
               struct servent *serv,
               struct servent_data *serv_data );

LIBRARY    [Toc]    [Back]

       Standard C Library (libc)

STANDARDS    [Toc]    [Back]

       Interfaces documented on this reference  page  conform  to
       industry standards as follows:

       getservent(): XNS4.0, XNS5.0

       Refer to the standards(5) reference page for more information
 about industry standards and associated tags.

PARAMETERS    [Toc]    [Back]

       [Tru64 UNIX]  For getservent_r() only, this points to  the
       servent  structure.   The  netdb.h header file defines the
       servent structure.  [Tru64 UNIX]  For getservent_r() only,
       this   points  to the servent_data structure.  The netdb.h
       header file defines the servent_data structure.

DESCRIPTION    [Toc]    [Back]

       The getservent() (get service entry)  function  opens  and
       reads the next line of either the local /etc/services file
       or the NIS distributed services  file  for  the  requested
       information.  To  determine which file or files to search,
       and in which order, the system uses the  switches  in  the
       /etc/svc.conf file.

       An  application  program can use the getservent() function
       to retrieve information about  network  services  and  the
       protocol ports they use.

       The  getservent()  function returns a pointer to a servent
       structure, which contains fields for a line of information
       from  the  network  services  database  file.  The servent
       structure is defined in the netdb.h header  file  as  follows:

       struct  servent {
               char     *s_name;         /* official service name
               char    **s_aliases;    /* alias list */
               int     s_port;         /* port # */
               char    *s_proto;       /* protocol to use */ };

       The network services database file remains  open  after  a
       call  by  the getservent() function.  Use the endservent()
       function to close the network services database file.  Use
       the setservent() function to rewind.

NOTES    [Toc]    [Back]

       The getservent() function returns a pointer to thread-specific
 data. Subsequent calls to this or a related function
       from the same thread overwrite this data.

       [Tru64  UNIX]  The  getservent_r() function is an obsolete
       reentrant version of the getservent() function and  should
       not  be  used in new designs. Note that you must zero-fill
       the servent_data structure before its first access by  the
       getservent_r() function.

RETURN VALUES    [Toc]    [Back]

       Upon  successful  completion,  the  getservent()  function
       returns a pointer to a servent structure.  If it fails  or
       reaches  the end of the network services database file, it
       returns a null pointer.

       [Tru64  UNIX]  Upon  successful  completion,  the  getservent_r()
  function  stores  the  servent  structure in the
       location pointed to by serv, and  returns  a  value  of  0
       (zero).  Upon failure, it returns a value of -1.

ERRORS    [Toc]    [Back]

       Current  industry standards do not define error values for
       the getservent() function.

       [Tru64 UNIX]  If any of the following  conditions  occurs,
       the  getservent_r() function sets errno to the corresponding
 value: The serv or  serv_data  parameter  is  invalid.
       The search failed.

       [Tru64  UNIX]  In  addition, if the function fails to open
       the file, it sets errno to indicate the cause of the failure.

FILES    [Toc]    [Back]

       The  Internet  network  service  name  database file. Each
       record in the file occupies a single  line  and  has  four
       fields:  the  official  service name, the port number, the
       protocol name, and aliases.  The database  service  selection
 configuration file.

SEE ALSO    [Toc]    [Back]

       Functions:   getservbyport(3),  getservbyname(3),  endservent(3), setservent(3)

       Files: services(4), svc.conf(4)

       Networks: nis_intro(7)

       Standards: standards(5)

       Network Programmer's Guide

[ Back ]
 Similar pages
Name OS Title
setservent_r Tru64 Open or rewind the services file
setservent Tru64 Open or rewind the services file
nondcesvc HP-UX file for dceping(8) that lists non-DCE services.
endservent Tru64 Close the network services database file.
endservent_r Tru64 Close the network services database file.
wellknownif HP-UX file for dceping(8) that contains the well-known interface IDs for core DCE and other services.
inetsvcs.conf HP-UX configuration file for secure internet services
nfssvc FreeBSD NFS services
nfssvc NetBSD NFS services
nfssvc OpenBSD NFS services
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service