getrpcent(3)
π getrpcent β bestie edition β¨
okay so today we're doing the getrpcent(3) girlies π«Ά this is a library-functions manual page, so grab a boba and let's get into it, because this is genuinely so much simpler than it looks.
These functions are basically your little backstage pass to the RPC program number database β like, they go get you the whole RPC entry, broken out into fields. π
πΈ LIBRARY
Standard C library (libc, -lc) β yeah yeah, the usual.
β¨ SYNOPSIS
#include <netdb.h>
struct rpcent *getrpcent(void);
struct rpcent *getrpcbyname(const char *name);
struct rpcent *getrpcbynumber(int number);
void setrpcent(int stayopen);
void endrpcent(void);
π DESCRIPTION
okay so the way this works: getrpcent(), getrpcbyname(), and getrpcbynumber() each hand you back a pointer to an object with this exact structure, all broken out with the fields of an entry from the RPC program number data base:
struct rpcent {
char *r_name; /* name of server for this RPC program */
char **r_aliases; /* alias list */
long r_number; /* RPC program number */
};
and the members of that struct, bestie, are honestly so straightforward:
r_nameβ the name of the server for this RPC program. π«r_aliasesβ aNULL-terminated list of alternate names for the RPC program. so like, the nicknames. the government names and the group-chat names, yk?r_numberβ the RPC program number for this service.
now the functions themselves:
- The
getrpcent()function reads the next entry from the database. if a connection isn't already open, it opens one. no connection, no entries, and it does it for you. generous queen. π - The
setrpcent()function opens a connection to the database, and sets the next entry to the first entry. ifstayopenis nonzero, then the connection to the database will not be closed between calls to one of thegetrpc*()functions β like, it just keeps the line open, iykyk. π₯ - The
endrpcent()function closes the connection to the database. that's it. that's her job. she's done her part. π - The
getrpcbyname()andgetrpcbynumber()functions sequentially search from the beginning of the file until a matching RPC program name or program number is found, or until end-of-file is encountered. so it's a full walk-through from the top, no shortcuts. πΆβοΈ
π RETURN VALUE
On success, getrpcent(), getrpcbyname(), and getrpcbynumber() return a pointer to a statically allocated rpcent structure. NULL is returned on EOF or error.
that "statically allocated" part is not a vibe you can ignore, bestie β more on that in BUGS below, because π
π FILES
/etc/rpcβ the RPC program number database. that's the one, that's the source of truth. β
π ATTRIBUTES
for an explanation of the terms used in this section, see attributes(7). and the deets, laid out pretty:
getrpcent(),getrpcbyname(),getrpcbynumber()β Thread safety: MT-Unsafe β οΈsetrpcent(),endrpcent()β Thread safety: MT-Safe locale β¨
so yeah, the getter trio is not thread safe, no cap. the setter/ender pair is safe with the locale caveat attached. π«Ά
π¦ STANDARDS
BSD. periodt.
π HISTORY
BSD, Solaris. she's got a heritage, an origin story, a whole lineage. π«
π BUGS
All information is contained in a static area so it must be copied if it is to be saved.
fr fr, bestie, this is the one that gets everyone. you cannot hold on to that pointer and expect it to still be your data later β it lives in a shared static spot and the next call will absolutely overwrite it. copy it. save your own copy. protect your peace. π
π SEE ALSO
and that's the whole page, babe π§ this was getrpcent(3), served to you fresh from Linux man-pages 6.20, dated 2025-05-17 β go forth and copy your static data before someone else does. mwah π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms