COHERENT manpages

This page displays the COHERENT manpage for getservent() [Get a service entry].

List of available manpages
Index


getservent() -- Sockets Function (libsocket)

Get a service entry
#include <netdb.h>
struct servent *getservent();

Function getservent()  reads the next entry  from file /etc/services, which
describes  the  services  offered by  TCP/IP  on  your  local network.   If
necessary, it opens the file.  It  returns a pointer to a structure of type
servent, which is defined in header file <netdb.h>:

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 following details each member:

s_name
     The official name of the service.

s_aliases
     This  points to  a  zero-terminated list  of alternate  names for  the
     service.

s_port
     The  port  number at  which  the service  resides.   Port numbers  are
     returned in network byte order.

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

To close /etc/services, call function endservent().

getservent() returns NULL  if an error occurs, or if  it encounters the end
of the file.

See Also

endservent(),
getservbyname(),
getservbyport(),
libsocket,
netdb.h,
setservent()

Notes

This function uses a static data  space.  If your application needs to save
these data, it must copy them before any subsequent calls overwrite them.