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

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

Contents


GETSERVENT(3N)							GETSERVENT(3N)


NAME    [Toc]    [Back]

     getservent, getservent_r, fgetservent, fgetservent_r, getservbyport,
     getservbyport_r, getservbyname, getservbyname_r, setservent, endservent -
     get service entry

SYNOPSIS    [Toc]    [Back]

     #include <netdb.h>

     struct servent *getservent(void);

     struct servent *getservent_r(struct servent *entry, char *buffer, int bufsize);

     struct servent *fgetservent(FILE *);

     struct servent *fgetservent_r(FILE	*, struct servent *entry, char *buffer,	int bufsize);

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

     struct servent *getservbyname_r(const char	*name, const char *proto, struct servent *entry, char *buffer, int bufsize);

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

     struct servent *getservbyport_r(int port, const char *proto, struct servent *entry, char *buffer, int bufsize);

     void setservent(int stayopen);

     void endservent(void);

DESCRIPTION    [Toc]    [Back]

     getservent, getservbyname,	getservbyport and their	reentrant counterparts
     each return a pointer to an object	with the following structure
     containing	the broken-out fields of a line	in the file /etc/services, or
     some other	back-end database.

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

     The members of this structure are:

     s_name	The official name of the service.

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

     s_port	The port number	at which the service  resides.	 Port  numbers
		are returned as	a 16-bit value in network byte order.






									Page 1






GETSERVENT(3N)							GETSERVENT(3N)



     s_proto	The name of the	protocol to use	when contacting	the service.

     Getservent	reads  the  next  line	of  the	 file,	opening	 the  file  if
     necessary.

     Setservent	opens and rewinds the file.  If	the stayopen flag is non-zero,
     the  net data base	will not be closed after each call to getservbyname or
     getservbyport.

     Endservent	closes the file.

     Getservbyname and getservbyport sequentially search from the beginning of
     the file until a matching protocol	name or	port number is found, or until
     EOF is encountered.  If a protocol	 name  is  also	 supplied  (non-NULL),
     searches must also	match the protocol.

     The routines fgetservent and fgetservent_r	return the next	entry from the
     supplied stream as	a struct servent structure.  The stream	must be	of the
     same format as the	file /etc/services.

     The functions getservent, fgetservent,  getservbyname  and	 getservbyport
     all  return  results in static memory which are overwritten on each call.
     Reentrant versions	of each	of these routines getservent_r,	fgetservent_t,
     getservbyname_r  and  getservbyport_r  are	 provided to parse the results
     into supplied memory.  They take three extra arguments, a	pointer	 to  a
     struct  servent  structure, a pointer to a	character buffer, and a	length
     for the buffer.

     The functions presented in	this manual  page  only	 parse	files  of  the
     format  given  in	services(4).   Other back-end databases	and protocols,
     such as NIS, can be supplied by the nsd(1M) daemon	as  specified  in  the
     nsd configuration file /etc/nsswitch.conf.

NOTE    [Toc]    [Back]

     The Mips ABI specifies nothing but	local files so applications which wish
     to	use anything else must compile with libc prior to libnsl in the
     library list.

     When nsd is running changes in the	local services file may	not be noticed
     by	getservent() until the enumeration cache file has timed	out.

DIAGNOSTICS    [Toc]    [Back]

     All functions that	return struct servent *	will return a null (0) pointer
     in	the case of EOF	or failure.

FILES    [Toc]    [Back]

     /etc/services /etc/nsswitch.conf /var/ns/cache/services.byname.m
     /var/ns/cache/services.byport.m







									Page 2






GETSERVENT(3N)							GETSERVENT(3N)



SEE ALSO
     nsd(1M), getprotoent(3N), services(4)

DIAGNOSTICS    [Toc]    [Back]

     Null pointer (0) returned on EOF or error.

BUGS    [Toc]    [Back]

     Expecting port numbers to fit in a	32-bit quantity	is probably naive.


									PPPPaaaaggggeeee 3333
[ 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