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 β€” a NULL-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. if stayopen is nonzero, then the connection to the database will not be closed between calls to one of the getrpc*() 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() and getrpcbynumber() 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