ENDNETENT(3POSIX)
πΈ ENDNETENT(3POSIX) β POSIX Programmer's Manual πΈ
okay bestie, we're doing the network database functions today and honestly? they're giving vintage but they're still lowkey useful. this is from the POSIX Programmer's Manual, periodt. π
β¨ PROLOG β¨
so like, heads up before we go any further: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (fr fr, go consult the corresponding Linux manual page for the deets on Linux behavior), or the interface might not even be implemented on Linux at all. π not every platform showed up to the party.
π NAME π
endnetent, getnetbyaddr, getnetbyname, getnetent, setnetent β network database functions. that's the whole squad. π«Ά
π¦ SYNOPSIS π¦
#include <netdb.h>
void endnetent(void);
struct netent *getnetbyaddr(uint32_t net, int type);
struct netnet *getnetbyname(const char *name);
struct netent *getnetent(void);
void setnetent(int stayopen);
wait no. let me try that again, that was NOT it. π
#include <netdb.h>
void endnetent(void);
struct netent *getnetbyaddr(uint32_t net, int type);
struct netent *getnetbyname(const char *name);
struct netent *getnetent(void);
void setnetent(int stayopen);
there we go. slay. β¨
π DESCRIPTION π
so these functions shall retrieve information about networks. this info is considered to be stored in a database that you can hit up either sequentially or randomly β the implementation of that database is unspecified, so don't come for it, it's mysterious on purpose. π
setnetent()β opens and rewinds the database. if thestayopenargument is non-zero, the connection to the net database shall not be closed after each call togetnetent()(whether that's directly, or indirectly through one of the othergetnet*()functions), and the implementation may keep an open file descriptor to the database just vibing in the background.getnetent()β reads the next entry of the database, opening and closing a connection to the database as necessary.getnetbyaddr()β searches the database from the very beginning and finds the first entry where the address family specified bytypematches then_addrtypemember and the network numbernetmatches then_netmember, opening and closing a connection to the database as necessary. thenetargument shall be the network number in host byte order. no cap.getnetbyname()β searches the database from the beginning and finds the first entry where the network name specified bynamematches then_namemember, opening and closing a connection to the database as necessary.getnetbyaddr(),getnetbyname(), andgetnetent()β each of these shall return a pointer to anetentstructure, and the members of that structure shall contain the fields of an entry in the network database. it's giving struct reveal. πendnetent()β closes the database, releasing any open file descriptor. clean exit, we love to see it.
bestie, important: these functions need not be thread-safe. so don't be out here assuming they'll play nice across threads, okay? π
β RETURN VALUE β
upon successful completion, getnetbyaddr(), getnetbyname(), and getnetent() shall return a pointer to a netent 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 shall be returned. that's the whole story. π«Ά
and now the part everyone skips and then gets burned by:
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 togetnetbyaddr(),getnetbyname(), orgetnetent(). the returned pointer, and pointers within the structure, might also be invalidated if the calling thread is terminated. π so like, copy what you need while you can. main character energy does not apply to this pointer.
π ERRORS π
no errors are defined. iconic, honestly. nothing to report. π
the following sections are informative.
π EXAMPLES π
none. moving on bestie, nothing to see here. π
π§ 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 .
and that's the whole page, bestie. IEEE/The Open Group, 2017 β mwah, go read your headers, drink some water, and remember: the returned pointer is temporary but you are forever. π«Άβ¨π
π¦ 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