FBB::Hostname(3bobcat)

πŸ’– FBB::Hostname β€” from the 3bobcat manual, bestie edition πŸ’–

okay so quick vibe check: this page lives in the 3bobcat section of the manual, and it's literally all about knowing who a host is. name? address? aliases? we got all of it. let's gooo πŸ¦‹

✨ NAME ✨

FBB::Hostname β€” the little class that holds name/address info about a host. it's giving "who are you and where do you live" but for computers 🫢

✨ SYNOPSIS ✨

#include <bobcat/hostname>
Linking option: -lbobcat

so you pull in the header, and when you link, you tack on -lbobcat. that's it, that's the whole ritual 🌸

✨ DESCRIPTION ✨

FBB::Hostname objects inherit from Hostent, and they hand you info about a host β€” just like Hostent does. the cute part: besides getting initialized from a hostname or a host address, you can also spin one up from an FBB::InetAddress object. and ngl, most of the stuff an FBB::Hostname can do is coming straight from its parent class FBB::Hostent. so Hostent is the main character here and Hostname is its adorable sidekick πŸ’…

✨ NAMESPACE ✨

FBB

every single constructor, member, operator and manipulator mentioned on this man-page is defined in the namespace FBB. no cap. πŸ‘‘

✨ INHERITS FROM ✨

FBB::Hostent

yup, it's a Hostent at heart. family tree = iconic 🌈

✨ CONSTRUCTORS ✨

  • Hostname() β€” the default constructor. it initializes an empty FBB::Hostname object. empty as in, no thoughts, head empty πŸ“
  • Hostname(std::string const &host) β€” this one initializes an FBB::Hostname object from a string that represents the name or the dotted decimal address of a host. and heads up bestie: if the hostname info could not be retrieved, an FBB::Exception object gets thrown. so wrap it, okay? 😭
  • Hostname(InetAddress const &inetAddress) β€” this one initializes an FBB::Hostname object from an InetAddress object. same deal: if the hostname information could not be retrieved, an FBB::Exception object is thrown. respect the try/catch, fr fr πŸ’€

Copy and move constructors (and assignment operators) are available β€” so copying and moving these around? slay, permitted, encouraged. ✨

✨ MEMBER FUNCTIONS ✨

every single member of FBB::Hostent is available to you, because FBB::Hostname inherits from that class. and guess what β€” there are no additional members. that's right, zero extra. it's purely a nepo baby who inherited everything πŸ‘‘πŸ’–

✨ EXAMPLE ✨

here's a little interactive toy that keeps asking you for a name or an address and then spills the tea about that host:

#include <iostream>

#include <bobcat/hostname>
#include <bobcat/exception>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    while (true)
    {
        cout << "Enter name or address:\n";

        string str;

        if (!getline(cin, str))
            return 0;

        if (str == "")
            break;

        try
        {
            Hostname h(str);

            cout << "Official name:\n";
                cout << h.hostname() << endl;

            cout << "Aliases:\n";
            for (size_t idx = 0; idx < h.nAliases(); idx++)
                cout << h.alias(idx) << " ";
            cout << endl;

            cout << "Adresses:\n";
            for (size_t idx = 0; idx < h.nAddresses(); idx++)
                cout << h.dottedDecimalAddress(idx) << " ";
            cout << endl;
        }
        catch (exception const &err)
        {
            cout << err.what() << endl;
        }
    }
}

(and yes, the Adresses: line is spelled exactly like that β€” we do not touch the code, periodt. πŸ”₯)

it loops forever, reads a line, bails out on EOF by returning 0, and breaks out of the loop when you just hit enter on an empty string. otherwise it builds a Hostname from whatever you typed and prints the official name, then every alias, then every dotted decimal address. and if anything blows up, the catch prints err.what() instead of crying about it. self-care 😌

✨ FILES ✨

  • bobcat/hostname β€” defines the class interface πŸŽ€

✨ SEE ALSO ✨

bobcat(7), hostent(3bobcat)

go read those too, bestie, they're the whole friend group 🫢

✨ BUGS ✨

None Reported. and honestly? iconic behaviour. no bugs, no drama, we love to see it πŸ’–βœ¨

✨ BOBCAT PROJECT FILES ✨

Debian Bobcat project files:

  • libbobcat6: the debian package containing the shared library, changelog and copyright note πŸ“¦
  • libbobcat-dev: the debian package containing the static library, headers, manual pages, and developer info πŸ“š

✨ BOBCAT ✨

Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’. 🐱 (yeah, that's the whole name and it ate.)

This is free software, distributed under the terms of the GNU General Public License (GPL). free as in freedom, bestie πŸ•ŠοΈβœ¨

✨ AUTHOR ✨

Frank B. Brokken (f.b.brokken@rug.nl). the legend himself πŸ‘‘


and that's the whole page, babes πŸ’… this came to you from libbobcat-dev_6.15.01, dated 2005-2026, filed under FBB::Hostname(3bobcat) β€” mwah, go forth and resolve some hostnames πŸ˜˜πŸ’–πŸŒΈ

πŸ“¦ where this page comes from