getservent()--Get Next Entry from Service Database


  Syntax
 #include <netdb.h>

 struct servent *getservent()

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: No; see Usage Notes.

The getservent() function is used to retrieve information about services (the protocol being used by the service and the port number assigned for the service). The information is retrieved from the services database file. When getservent() is first called, the file is opened, and the first entry is returned. Each subsequent call to getservent() results in the next entry in the file being returned. To close the file, use endservent().


Authorities

No authorization is required.


Return Value

getservent() returns a pointer. Possible values are:

The structure struct servent is defined in <netdb.h>.


Usage Notes

  1. The iSeries Navigator or the following CL commands can be used to access the services database file:
  2. The pointer returned by getservent() points to static storage that is overwritten on subsequent calls to the getservent(), getservbyname(), or getservbyport() functions.

  3. A coded character set identifier (CCSID) of 65535 for the job requests that no database translation be performed. For translation to occur for the service names returned in the servent structure, the job CCSID must be something other than 65535.

  4. Do not use the getservent() function in a multithreaded environment. See the multithread alternative getservent_r() function.

  5. When you develop in C-based languages and an application is compiled with the _XOPEN_SOURCE macro defined to the value 520 or greater, the getservent() API is mapped to qso_getservent98().

Related Information



API introduced: V4R2
Top | UNIX-Type APIs | APIs by category