endservent(), getservbyname(), getservbyport(), getservent(), setservent()

get network servcol database information 

Function


SYNOPSIS

#include <netdb.h>

void endservent();

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

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

struct servent *getservent(void);

void setservent(int stayopen);


DESCRIPTION

The getservent(), getservbyname(), and getservbyport() functions each return a pointer to a servent structure, the members of which contain the fields of an entry in the network servcol database, as follows:

s_name 

Official name of the protocol.

s_aliases 

A null-terminated array of alternate names.

s_port 

The port number at which the service resides, in network byte order.

s_proto 

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

The getservent() function reads the next entry of the database, opening a connection to the database if necessary.

The getservbyname() function searches the database and finds an entry which matches the specified service name and the specified protocol, opening a connection to the database if necessary.

The getservbyport() function searches the database and finds an entry which matches the specified port number and the specified protocol, opening a connection to the database if necessary.

The setservent() function opens a connection to the network host database, and sets the position of the next entry to the first entry. If its parameter is non-zero, the connection to the database is not closed after each call to getservent() (either directly, or indirectly through getservbyname() or getservbyport()).

The endservent() function closes the connection to the database.


PARAMETERS

name 

Is the service name for the service whose entry is to be returned.

proto 

Is the protocol name for the service whose entry is to be returned. If this is a null pointer, then any protocol is matched.

port 

Is the port number for the service whose entry is to be returned. This must be in network byte order.

stayopen 

When non-zero, the connection to the database is not closed after each call to getservent().


RETURN VALUES

If successful, getservbyaddr(), getservbyname(), and getservent() return a pointer to the servent structure described in the DESCRIPTION section. On failure, they return a null pointer.

The pointer that is returned points to a structure that is allocated by the NuTCRACKER Platform. The application must never attempt to modify this structure or to free any of its components. Furthermore, only one copy of this structure is allocated per thread; therefore, the application should copy any information it needs before issuing any other socket calls.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

endservent(), getservent(), setservent(): Unsafe.

getservbyname(), getservbyport(): MT-Safe.


PORTING ISSUES

On 10/2016/2019/11/2022/2025, the services file is in the drivers/etc directory under the 10/2016/2019/11/2022/2025 system directory. The _NutQueryWinNetFileDir() function returns the path where the network database files are located, regardless of platform.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutQueryWinNetFileDir(), endhostent(), endnetent(), endprotoent(), gethostbyaddr(), gethostbyname(), gethostent(), getnetbyaddr(), getnetbyname(), getnetent(), getprotobyname(), getprotobynumber(), getprotoent(), htons(), ntohs(), sethostent(), setnetent(), setprotoent()


PTC MKS Toolkit 10.5 Documentation Build 40.