ENDHOSTENT(3P)
π ENDHOSTENT(3P) β bestie edition π
ok so this one is from the POSIX Programmer's Manual, page ENDHOSTENT(3P), and it's literally about the network host database. pull up a chair π«Ά
πΈ PROLOG πΈ
quick lil heads up before we get into it: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β so if you're on Linux, go consult the corresponding Linux manual page for the tea on Linux behavior. or, plot twist, the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
endhostent, gethostent, sethostent β network host database functions. that's the whole vibe. three functions, one host database, infinite possibilities π
π SYNOPSIS π
#include <netdb.h>
void endhostent(void);
struct hostent *gethostent(void);
void sethostent(int stayopen);
look at that. clean. gorgeous. no notes. β
π¦ DESCRIPTION π¦
okay so these functions shall retrieve information about hosts. and where does that info live? in a database β one that can be accessed sequentially or randomly, bestie. and the implementation of that database? unspecified. we don't know her. we just work with her. π
Note: in many cases this database is implemented by the Domain Name System, as documented inRFC 1034,RFC 1035, andRFC 1886. so like. DNS. iykyk. π
here's the breakdown, function by function:
sethostent()β shall open a connection to the database and set the next entry for retrieval to the first entry in the database. and if thestayopenargument is non-zero? the connection shall not be closed by a call togethostent(), and the implementation may maintain an open file descriptor. keeping it open, keeping it cozy. π₯gethostent()β shall read the next entry in the database, opening and closing a connection to the database as necessary. very "i'll come and go as i please" energy honestly.endhostent()β shall close the connection to the database, releasing any open file descriptor. she's the one who says goodbye at the end of the party. bye bestie π
entries shall be returned in hostent structures. that's the container, that's the shape, that's the moment. β¨
big important warning: these functions need not be thread-safe. so like, don't be chaotic about it. no cap.
π RETURN VALUE π
upon successful completion, the gethostent() function shall return a pointer to a hostent 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. found it = pointer. didn't find it / ran out = null. simple as that. π«
now listen closely, because this part matters:
do NOT touch the structure. the application shall not modify the structure to which the return value points, nor any storage areas pointed to by pointers within the structure. hands off. π«
and it gets spicier: 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 gethostent(). π
the returned pointer, and pointers within the structure, might also be invalidated if the calling thread is terminated. so like... don't let your thread die mid-use, or your pointer's just gone. periodt.
π ERRORS π
no errors are defined for endhostent(), gethostent(), and sethostent(). zero. none. nadda. clean slate, iconic behavior. β¨
the following sections are informative. (so like, they're context, not rules. we're just chatting now. π)
π EXAMPLES π
None. π
πΈ APPLICATION USAGE πΈ
None. π
π§ RATIONALE π§
None. π
β FUTURE DIRECTIONS β
None. π
π SEE ALSO π
endservent()- The Base Definitions volume of POSIX.1β2017,
<netdb.h>
go read those next, bestie, they're lowkey important. π«Ά
π COPYRIGHT π
okay, legal girlies, gather round:
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, babes. brought to you by IEEE/The Open Group, 2017 β signing off from ENDHOSTENT(3P), stay slay, stay thread-unsafe-aware, and please don't modify that struct. πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms