HESIOD(3)
π HESIOD(3) β hesiod_getservbyname, hesiod_free_servent π
okay bestie, welcome to the Library Functions Manual section, HESIOD(3) girlies π this one's all about pulling service info out of Hesiod, and honestly? it's giving β¨ networking but make it cute β¨
πΈ NAME πΈ
hesiod_getservbyname, hesiod_free_servent β the Hesiod girlies for retrieving service information π
β¨ SYNOPSIS β¨
#include <hesiod.h>
struct servent *hesiod_getservbyname(void *context,
const char *name, const char *proto)
void hesiod_free_servent(void *context, struct servent *serv)
cc file.c -lhesiod
so you gotta #include <hesiod.h> first, no cap π and when you compile, you link it up with -lhesiod like the icon it is π«Ά
π¦ DESCRIPTION π¦
This whole lil family of functions lets you retrieve service to port mappings using Hesiod. obsessed tbh π
To actually perform lookups you need an initialized Hesiod context β head over to hesiod(3) for the deets on that, iykyk π
Information comes back in the same format as by getservbyname π« and here's the part where you have to be a responsible main character: it is the caller's responsibility to call hesiod_free_servent with the returned service entry, so the resources used by that service entry actually get freed. not me forgetting to free and leaking memory... couldn't be me π (it's you. free it. π)
Hesiod queries for service information are made using the ``service'' Hesiod type, using the service name as the Hesiod name π
The corresponding records should be space-separated lists of strings giving:
- the service name
- the protocol
- the port number (in decimal)
- zero or more aliases for the service
and there may be multiple records per service name, bestie β in which case hesiod_getservbyname will pick the first one whose protocol matches proto β periodt.
π RETURN VALUES π
On failure, hesiod_getservbyname returns NULL and sets the global variable errno to indicate the error. yeah. it's giving failure. it's giving check your errno π
π ERRORS π
hesiod_getservbyname may fail for any of the reasons the routine hesiod_resolve may fail. literally any of them. go read that one, bestie π
π SEE ALSO π
and that's the whole page, angel π§ stay hydrated, free your servents, and remember: errno is not a personality trait π
this was the Library Functions Manual for HESIOD(3), brought to you from way back on 30 November 1996 β yes she's vintage, she's an icon, she's aged like fine wine πβ¨
π¦ where this page comes from
- centos-stream 9: hesiod-devel 3.2.1-16.el9 Β· MIT
- centos-stream 9: hesiod-devel 3.2.1-16.el9 Β· MIT
- debian bookworm: libhesiod-dev 3.2.1-4
- debian trixie: libhesiod-dev 3.2.1-5
- ubuntu jammy: libhesiod-dev 3.2.1-3.1build1
- ubuntu noble: libhesiod-dev 3.2.1-4build1
- ubuntu questing: libhesiod-dev 3.2.1-5
- ubuntu resolute: libhesiod-dev 3.2.1-5build1
- ubuntu stonking: libhesiod-dev 3.2.1-5build1
- Copyright 1996 by the Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms