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

  man pages->Linux man pages -> getservent (3)              
Title
Content
Arch
Section
 

GETSERVENT(3)

Contents


NAME    [Toc]    [Back]

       getservent,  getservbyname, getservbyport, setservent, endservent - get
       service entry

SYNOPSIS    [Toc]    [Back]

       #include <netdb.h>

       struct servent *getservent(void);

       struct servent *getservbyname(const char *name, const char *proto);

       struct servent *getservbyport(int port, const char *proto);

       void setservent(int stayopen);

       void endservent(void);

DESCRIPTION    [Toc]    [Back]

       The getservent() function reads the next line from the  file  /etc/ser-
       vices  and returns a structure servent containing the broken out fields
       from the line.  The /etc/services file is opened if necessary.

       The getservbyname() function returns a servent structure for  the  line
       from  /etc/services that matches the service name using protocol proto.
       If proto is NULL, any protocol will be matched.

       The getservbyport() function returns a servent structure for  the  line
       that  matches  the port port given in network byte order using protocol
       proto. If proto is NULL, any protocol will be matched.

       The setservent() function opens and rewinds the /etc/services file.  If
       stayopen is true (1), then the file will not be closed between calls to
       getservbyname() and getservbyport().

       The endservent() function closes /etc/services.

       The servent structure is defined in <netdb.h> as follows:

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

       The members of the servent structure are:

       s_name The official name of the service.

       s_aliases
	      A zero terminated list of alternative names for the service.

       s_port The port number for the service given in network byte order.

       s_proto
	      The name of the protocol to use with this service.

RETURN VALUE    [Toc]    [Back]

       The getservent(), getservbyname() and getservbyport() functions	return
       the  servent structure, or a NULL pointer if an error occurs or the end
       of the file is reached.

FILES    [Toc]    [Back]

       /etc/services
	      services database file

CONFORMING TO    [Toc]    [Back]

       BSD 4.3

SEE ALSO    [Toc]    [Back]

      
      
       getprotoent(3), getnetent(3), services(5)



BSD				  2001-07-25			 GETSERVENT(3)
[ Back ]
 Similar pages
Name OS Title
rpccp_add_member HP-UX Adds a member to a group in a name service entry; if the specified entry does not exist, creates the entry
rpccp_add_element HP-UX Adds an element to a profile in a name service entry; if the specified entry does not exist, creates the entry
rpccp_add_entry HP-UX Adds a name service entry to the name service database
rpccp_remove_entry HP-UX Removes a name service entry from the name service database
getservbyname_r Tru64 Get a service entry by name
getservbyname Tru64 Get a service entry by name
getservbyport Tru64 Get a service entry by port number
getservbyport_r Tru64 Get a service entry by port number
rpccp_show_entry HP-UX Shows the NSI attributes of a name service entry
rpccp_remove_profile HP-UX Removes all profile elements and the profile from the specified name service entry
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service