Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

getservent_r(3) OSS Library Calls Reference Manual
On systems running H06.24 or later H-series RVUs or J06.13 or later J-series RVUs, you can use |
this function with 32-bit applications or 64-bit applications unless you are using the Standard |
POSIX Threads Library.
If you are NOT using the Standard POSIX Threads Library (this is not a threaded application or
you are using the POSIX User Thread Model Library), you must:
Include the netdb.h header file
If you are using the Standard POSIX Threads library, you must:
Include the spthread.h header file
Link your application to:
/G/system/sysnn/zsptsrl (G-series)
or
/G/system/zdllnnn/zsptdll (H-series or J-series)
Compile your application using the #define _SPT_MODEL_ macro or an equivalent
compiler command option
If you are using this function in a threaded or 64-bit application in a system running H06.21 or a |
later H-series RVU or J06.10 or a later J-series RVU, you might need to include additional files |
or use additional macros. For more information about threaded and 64-bit applications in the |
OSS environment, see the Open System Services Programmers Guide.
In a threaded environment, the behavior of the application is undetermined if more than one
thread in application is calling different sequences of the setservent(), getservbyport(),
getservbyport_r( ), getservbyname( ), getservbyname_r( ), or endservent( ) functions.
RETURN VALUES
Upon successful completion, the getservent_r() function returns a pointer to a servent structure.
If an error occurs or the end of the file is reached, the getservent_r( ) function returns a null
pointer. If an entry is found, the pointer returned by this function points to the same servent
structure as pointed to by the result parameter.
The structure of type servent is defined in the netdb.h header file as:
struct servent {
char *s_name;
char **s_aliases;
int s_port;
char s_proto;
};
The fields of this structure are:
s_name Points to the official name of the service.
s_aliases Points to a zero-terminated list of alternate names for the service.
s_port The port number at which the service resides. Port numbers are returned in net-
work byte order.
s_proto The name of the protocol to use when contacting the service.
3146 Hewlett-Packard Company 527187-017