NAME(3)
β¨ NAME β¨
krb5_getportbyname β bestie, it gets you a port number by name π
Okay so this is a page from the Library Functions Manual, section 3, and it's about one tiny little function that does exactly one thing and does it slayfully. Let's get into it π«Ά
π LIBRARY
This one lives in the Kerberos 5 Library β that's libkrb5, and you link it with -lkrb5. Iconic. No notes. β¨
πΈ SYNOPSIS
#include <krb5.h>
int
krb5_getportbyname(krb5_context context, const char *service,
const char *proto, int default_port);
Yes she takes four arguments. Yes that's a lot of words for "gimme a port number." We move π
π DESCRIPTION
So here's the tea, bestie π β krb5_getportbyname() goes and grabs the port number for a service / proto pair, pulling it straight out of the global service table, and hands it back to you in network order. Periodt.
But β and this is the part where it's giving safety net π§ β if that pair isn't in the global table at all? Not a problem. It just gives you default_port instead. And heads up, that default_port is given in host order, not network order. Lowkey important. Don't mix them up π
Two orders, two vibes: the real answer comes back in network order, the fallback you hand in is in host order. That's just how she is π
π EXAMPLE
Here's literally the whole thing in one line, bestie:
int port = krb5_getportbyname(context, "kerberos", "tcp", 88);
Look at her go. Service "kerberos", proto "tcp", and if the global table's got nothing to say about it, we're falling back to 88. Ate. π₯
π SEE ALSO
krb5(3)β the mothership. Go read her next, fr fr π
This page comes to you from HEIMDAL, dated August 15, 2004 β yes she's vintage, yes she still eats, and she's filed under NAME(3) in the manual. Mwah, take care of her πβ¨
π¦ where this page comes from
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- debian bookworm: heimdal-dev 7.8.git20221117.28daf24+dfsg-2 Β· BSD-3-Clause
- debian trixie: heimdal-dev 7.8.git20221117.28daf24+dfsg-9+deb13u1 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- freebsd 14.5: base 14.5
- nixpkgs unstable: heimdal 7.8.0-unstable-2024-09-10
- ubuntu jammy: heimdal-dev 7.7.0+dfsg-3ubuntu1 Β· BSD-3-Clause
- ubuntu noble: heimdal-dev 7.8.git20221117.28daf24+dfsg-5ubuntu3 Β· BSD-3-Clause
- ubuntu questing: heimdal-dev 7.8.git20221117.28daf24+dfsg-9ubuntu1
- ubuntu resolute: heimdal-dev 7.8.git20221117.28daf24+dfsg-11ubuntu1 Β· BSD-3-Clause
- ubuntu stonking: heimdal-dev 7.8.git20240113.1b4565a+dfsg-2ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2004 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms