ENDSERVENT(3P)
π ENDSERVENT(3P) π
okay bestie, welcome to the POSIX Programmer's Manual entry for endservent, getservbyname, getservbyport, getservent and setservent β the whole network services database friend group π«Ά
β¨ PROLOG β¨
so like, real talk first: 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 at all. it's giving "check your local listings" energy π
πΈ NAME πΈ
endservent, getservbyname, getservbyport, getservent, setservent β network services database functions. yes that's five (5) functions, one iconic little squad π
π SYNOPSIS π
#include <netdb.h>
void endservent(void);
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int port, const char *proto);
struct servent *getservent(void);
void setservent(int stayopen);
copy that exactly bestie, no typos, the compiler WILL clock you π
π¦ DESCRIPTION π¦
So. These functions shall retrieve information about network services. This information is considered to be stored in a database that can be accessed sequentially or randomly β like a playlist you can either shuffle or scroll through in order. The implementation of this database is unspecified, so don't come for it, it's mysterious on purpose π
The setservent() function shall open a connection to the database, and set the next entry to the first entry. If the stayopen argument is non-zero, the net database shall not be closed after each call to the getservent() function (either directly, or indirectly through one of the other getserv*() functions), and the implementation may maintain an open file descriptor for the database. lowkey it's like leaving the group chat open instead of exiting and re-entering every single time π
The getservent() function shall read the next entry of the database, opening and closing a connection to the database as necessary.
The getservbyname() function shall search the database from the beginning and find the first entry for which the service name specified by name matches the s_name member and the protocol name specified by proto matches the s_proto member, opening and closing a connection to the database as necessary. If proto is a null pointer, any value of the s_proto member shall be matched. so like, proto being null = "any protocol, idc, surprise me" β¨
The getservbyport() function shall search the database from the beginning and find the first entry for which the port specified by port matches the s_port member and the protocol name specified by proto matches the s_proto member, opening and closing a connection to the database as necessary. If proto is a null pointer, any value of the s_proto member shall be matched. The port argument shall be a value obtained by converting a uint16_t in network byte order to int. write that down, it matters fr fr π₯
The getservbyname(), getservbyport(), and getservent() functions shall each return a pointer to a servent structure, the members of which shall contain the fields of an entry in the network services database.
The endservent() function shall close the database, releasing any open file descriptor. it's the "okay bye, love u, talk later" function π₯Ή
These functions need not be thread-safe. so like, do NOT pass them around the friend group and assume everyone gets along. be careful bestie π
π RETURN VALUE π
Upon successful completion, getservbyname(), getservbyport(), and getservent() return a pointer to a servent 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. aww, no entry? null pointer. reached the end? also null pointer. it's giving "same energy, different reason" π
The application shall not modify the structure to which the return value points, nor any storage areas pointed to by pointers within the structure. that's not yours, don't touch it π βοΈ
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 getservbyname(), getservbyport(), or getservent(). The returned pointer, and pointers within the structure, might also be invalidated if the calling thread is terminated.
so basically: use it, love it, screenshot it if you need it later, because it can get yeeted out from under you at any moment π
π ERRORS π
No errors are defined.
The following sections are informative. (translation: the actual spec business is done, everything after this is β¨bonus contentβ¨)
π EXAMPLES π
None. yeah. nothing. empty. the void. π
π§ APPLICATION USAGE π§
The port argument of getservbyport() need not be compatible with the port values of all address families. noted π
β RATIONALE β
None. iconic of them honestly π
π FUTURE DIRECTIONS π
None.
π₯ SEE ALSO π₯
endhostent()endprotoent()htonl()inet_addr()
The Base Definitions volume of POSIX.1β2017, <netdb.h>
go read those too bestie, it's a whole universe π
π 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!! brought to you by IEEE/The Open Group, 2017 edition, for ENDSERVENT(3P) π«Άβ¨ go forth and look up your services, ily, bye!! π ππ¦
π¦ 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