GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


Manpage of GETSERVENT

GETSERVENT

Index
 

NAME

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

SYNOPSIS

#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

The fBgetservent()fP function reads the next line from the file fI/etc/servicesfP and returns a structure fIserventfP containing the broken out fields from the line. The fI/etc/servicesfP file is opened if necessary.

The fBgetservbyname()fP function returns a fIserventfP structure for the line from fI/etc/servicesfP that matches the service fInamefP using protocol fIprotofP. If fIprotofP is NULL, any protocol will be matched.

The fBgetservbyport()fP function returns a fIserventfP structure for the line that matches the port fIportfP given in network byte order using protocol fIprotofP. If fIprotofP is NULL, any protocol will be matched.

The fBsetservent()fP function opens and rewinds the fI/etc/servicesfP file. If fIstayopenfP is true (1), then the file will not be closed between calls to fBgetservbyname()fP and fBgetservbyport()fP.

The fBendservent()fP function closes fI/etc/servicesfP.

The fIserventfP structure is defined in fI<netdb.h>fP 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 fIserventfP 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

The fBgetservent()fP, fBgetservbyname()fP and fBgetservbyport()fP functions return the fIserventfP structure, or a NULL pointer if an error occurs or the end of the file is reached.  

FILES

/etc/services
services database file
 

CONFORMING TO

BSD 4.3  

SEE ALSO

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


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
FILES
CONFORMING TO
SEE ALSO