getprotobyname()--Get Protocol Information for Protocol Name
BSD 4.3 Syntax
#include <netdb.h>
struct protoent *getprotobyname(char *protocol_name)
Service Program Name: QSOSRV2
Default Public Authority: *USE
Threadsafe: No; see
Usage Notes.
UNIX 98 Compatible Syntax
#define _XOPEN_SOURCE 520
#include <netdb.h>
struct protoent *getprotobyname(const char *protocol_name)
Service Program Name: QSOSRV2
Default Public Authority:*USE
Threadsafe: No; see
Usage
Notes.
The getprotobyname() function is used to retrieve information about
a protocol. The information is retrieved from the protocol database file.
There are two versions of the API, as shown above. The base i5/OS API uses BSD 4.3
structures and syntax. The other uses syntax and structures compatible with the UNIX 98
programming interface specifications. You can select the UNIX 98 compatible
interface with the _XOPEN_SOURCE macro.
Parameters
- protocol_name
- (Input) The pointer to the character string that contains the name of the
protocol for which information is to be retrieved.
Authorities
No authorization is required.
Return Value
getprotobyname() returns a pointer. Possible values are:
- NULL (unsuccessful)
- p (successful), where p is a pointer to struct
protoent
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.
- The iSeries Navigator or the following CL commands can be
used to access the protocol database file:
- WRKPCLTBLE (Work with Protocol Table Entries)
- ADDPCLTBLE (Add Protocol Table Entry)
- RMVPCLTBLE (Remove Protocol Table Entry)
- The pointer returned by getprotobyname() points to static storage
that is overwritten on subsequent calls to the getprotobyname(),
getprotobynumber(), or getprotoent() functions.
- 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.
- 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
name specified by the protocol_name parameter, and for the protocol
names returned in the protoent structure, the job CCSID must be something other
than 65535.
- Do not use the getprotobyname() function in a multithreaded
environment. See the multithread alternative getprotobyname_r()
function.
- 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 getprotobyname() API is mapped to
qso_getprotobyname98().
Related Information
API introduced: V4R2