getprotobynumber()--Get Protocol Information for Protocol Number


  Syntax
 #include <netdb.h>

 struct protoent
        *getprotobynumber(int protocol_number)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: No; see Usage Notes.

The getprotobynumber() function is used to retrieve information about a protocol. The information is retrieved from the protocol database file.


Parameters

protocol_number
(Input) The protocol number for which information is to be retrieved.

Authorities

No authorization is required.


Return Value

getprotobynumber() returns a pointer. Possible values are:

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

      struct protoent {
        char            *p_name;
        char            **p_aliases;
        int             p_proto;
      };

p_name points to the character string that contains the name of the protocol. p_aliases is a pointer to a NULL-terminated array of alternate names for the protocol. p_proto is the protocol number.


Usage Notes

  1. System i® Navigator or the following CL commands can be used to access the protocol database file:


  2. The pointer returned by getprotobynumber() points to static storage that is overwritten on subsequent calls to the getprotobynumber(), getprotobyname(), or getprotoent() functions.

  3. When the protocol information is obtained from the protocol database file, the file is opened and the protocol information is retrieved (if it exists) from the file. The file is then closed only if a setprotoent() with a nonzero parameter value was not previously done.

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

  5. Do not use the getprotobynumber() function in a multithreaded environment. See the multithread alternative getprotobynumber() function.

  6. 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 getprotobynumber() API is mapped to qso_getprotobynumber98().

Related Information



API introduced: V4R2

[ Back to top | UNIX-Type APIs | APIs by category ]