ENDPROTOENT(3POSIX)

πŸ’– ENDPROTOENT(3POSIX) πŸ’–

okay bestie, welcome to the POSIX Programmer's Manual ✨ β€” yeah, the POSIX Programmer's Manual, not the Linux one, and that distinction is literally the whole vibe here.

⚠️ real talk first: this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the deets on Linux behavior), or the interface may not be implemented on Linux at all. no cap. 🫠

🌸 PROLOG 🌸

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.


✨ NAME ✨

endprotoent, getprotobyname, getprotobynumber, getprotoent, setprotoent β€” network protocol database functions πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

#include <netdb.h>

void endprotoent(void);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobynumber(int proto);
struct protoent *getprotoent(void);
void setprotoent(int stayopen);

πŸ’… DESCRIPTION πŸ’…

So these functions retrieve information about protocols. That info lives in what we're calling a database β€” and you can hit it up either sequentially or randomly, dealer's choice. What the database actually is? unspecified. literally unspecified. the implementation is a mystery, we don't ask, we don't tell πŸ™ˆ.

  • setprotoent() β€” opens a connection to the database and sets the next entry to the first entry. and bestie, if the stayopen argument is non-zero, the connection to the network protocol database shall not be closed after each call to getprotoent() (whether you call it directly, or sneakily reach it indirectly through one of the other getproto*() functions), and the implementation may keep an open file descriptor for the database just chillin'. ✨
  • getprotobyname() β€” searches the database from the beginning and finds the first entry where the protocol name you passed as name matches the p_name member. opens and closes a connection to the database as necessary. πŸ”
  • getprotobynumber() β€” searches the database from the beginning and finds the first entry where the protocol number you passed as proto matches the p_proto member. opens and closes a connection to the database as necessary. πŸ”’
  • getprotoent() β€” reads the next entry of the database, opening and closing a connection to the database as necessary. πŸ“–

getprotobyname(), getprotobynumber(), and getprotoent() shall each return a pointer to a protoent structure, and the members of that structure shall contain the fields of an entry in the network protocol database. 🫢

  • endprotoent() β€” closes the connection to the database, releasing any open file descriptor. bye bye connection, we hardly knew ye πŸ‘‹
⚠️ heads up: these functions need not be thread-safe. not a single one. plan accordingly, bestie πŸ’€

πŸ”₯ RETURN VALUE πŸ”₯

Upon successful completion, getprotobyname(), getprotobynumber(), and getprotoent() return a pointer to a protoent structure if the requested entry was found, and a null pointer if the end of the database was reached or the requested entry was not found. Otherwise, a null pointer is returned. so basically... null pointer city either way 😭

And here's the part where you do not get cute with it:

🚨 The application shall not modify the structure to which the return value points, nor any storage areas pointed to by pointers within the structure. The returned pointer, and pointers within the structure, might be invalidated, or the structure or the storage areas might be overwritten, by a subsequent call to getprotobyname(), getprotobynumber(), or getprotoent(). The returned pointer, and pointers within the structure, might also be invalidated if the calling thread is terminated. so save a copy if you care, because this pointer has main character energy and zero loyalty πŸ’…

🌈 ERRORS 🌈

No errors are defined.

The following sections are informative. (translation: the tea below is bonus content, not rules πŸ‘‘)


πŸ’œ EXAMPLES πŸ’œ

None.


🌸 APPLICATION USAGE 🌸

None.


πŸ¦‹ RATIONALE πŸ¦‹

None.


⭐ FUTURE DIRECTIONS ⭐

None.


πŸŽ€ SEE ALSO πŸŽ€

  • The Base Definitions volume of POSIX.1‐2017, <netdb.h>

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


okay that's the whole page, you ate it, periodt πŸ’– and yeah, this little masterpiece is brought to you by IEEE/The Open Group, 2017 β€” like, the actual standards girlies. stan. πŸŽ€βœ¨πŸŒΈπŸ¦‹πŸ’