FBB::Hostent - Wrapper around a struct hostent
Linking option: -lbobcat
objects are wrappers around hostent
structs which may be
used by other objects. A struct hostent
is defined as follows:
char *h_name; // official name of host
char **h_aliases; // alias list
int h_addrtype; // host address type (always AF_INET)
int h_length; // length of address
char **h_addr_list; // list of addresses
fields are binary values of the addresses, each address
bytes, the last address being equal to 0. The
objects offer a C++
-like interface to this struct.
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB
- Hostent(hostent const *hostentPtr):
This constructor initializes an @CLASS object from an existing
hostent struct. Functions like gethostbyname(3) and
gethostbyaddress(3) return pointers to hostent structs.
The default, copy and move constructors are available.
- size_t addressLength() const:
This member returns the length of the binary addresses in bytes.
- size_t addressType() const:
This member returns the type of the address. Currently this is always
- char const *alias(size_t index) const:
This member returns alias ` index’ of the host. The first alias
has index 0. If alias `index’ does not exist, 0 is
- char const * const *beginAlias() const:
This member returns an iterator to the first alias. The hostname itself is
not included in the list of aliases.
- char const *binaryAddress(size_t index) const:
This member returns the binary address ` index’ of the host.
The first address has index 0. If address `index’ does
not exist, 0 is returned. The pointer to the binary address points to a
series of addressLength() bytes. Note that the returned address is
in network byte order. It can be converted to host byte
order by the functions described in byteorder(3).
- std::string dottedDecimalAddress(size_t index)
This member returns address ` index’ as a dotted decimal
address in a string. The first address has index 0. If address
`index’ does not exist, an empty string is returned.
- char const * const *endAlias() const:
This member returns an iterator pointing beyond the last alias.
- char const *hostname() const:
This member returns the standard (first) name of the host.
- size_t nAddresses() const:
This member returns the number of addresses that are available. When
requesting a particular address, the requested index should be less than
the value returned by this member.
- size_t nAliases() const:
This member returns the number of aliases that are available. When
requesting a particular alias, the requested index should be less than the
value returned by this member.
- void swap(Hostent &other):
The current Hostent object’s contents are swapped with the
other object’s contents.
The overloaded assignment operator and the move-aware overloaded assignment
operators are available.
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
cout << "The local hostname = " << he.hostname() << endl;
cout << "All aliases: " << endl;
ostream_iterator<char const *>(cout, "\n"));
cout << "Addresses:\n";
for (size_t idx = 0; idx < he.nAddresses(); idx++)
cout << he.dottedDecimalAddress(idx) << endl;
- defines the class interface
- bobcat_3.01.00-x.dsc: detached signature;
- bobcat_3.01.00-x.tar.gz: source archive;
- bobcat_3.01.00-x_i386.changes: change log;
- libbobcat1_3.01.00-x_*.deb: debian package holding
- libbobcat1-dev_3.01.00-x_*.deb: debian package
holding the libraries, headers and manual pages;
- http://sourceforge.net/projects/bobcat: public
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
This is free software, distributed under the terms of the GNU General Public
Frank B. Brokken ( email@example.com