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 thestayopenargument is non-zero, the connection to the network protocol database shall not be closed after each call togetprotoent()(whether you call it directly, or sneakily reach it indirectly through one of the othergetproto*()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 asnamematches thep_namemember. 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 asprotomatches thep_protomember. 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 togetprotobyname(),getprotobynumber(), orgetprotoent(). 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>
π COPYRIGHT π
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. πβ¨πΈπ¦π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms