1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
includefile(include/header)
COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::Hostent)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
(struct hostent wrapper)
manpagename(FBB::Hostent)(Wrapper around a bf(struct hostent))
manpagesynopsis()
bf(#include <bobcat/hostent>)nl()
Linking option: tt(-lbobcat)
manpagedescription()
bf(@CLASS) objects are wrappers around bf(hostent) structs which may be
used by other objects. A bf(struct hostent) is defined as follows:
verb(
struct hostent
{
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
}
)
The tt(address) fields are binary values of the addresses, each address
requiring tt(h_length) bytes, the last address being equal to 0. The
bf(@CLASS) objects offer a bf(C++)-like interface to this struct.
includefile(include/namespace)
manpagesection(INHERITS FROM)
-
manpagesection(CONSTRUCTORS)
itemization(
itb(Hostent(hostent const *hostentPtr))
This constructor initializes an bf(@CLASS) object from an existing
bf(hostent) struct. Functions like bf(gethostbyname)(3) and
bf(gethostbyaddress)(3) return pointers to bf(hostent) structs.
)
The default, copy and move constructors (and the copy and move assignment
operators) are available.
manpagesection(MEMBER FUNCTIONS)
itemization(
itb(size_t addressLength() const)
This member returns the length of the binary addresses in bytes.
itb(size_t addressType() const)
This member returns the type of the address. Currently this is always
bf(AF_INET).
itb(char const *alias(size_t index) const)
This member returns alias `tt(index)' of the host. The first alias has
tt(index 0). If alias `tt(index)' does not exist, 0 is returned.
itb(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.
itb(char const *binaryAddress(size_t index) const)
This member returns the binary address `tt(index)' of the host. The
first address has tt(index 0). If address `tt(index)' does not exist, 0 is
returned. The pointer to the binary address points to a series of
bf(addressLength()) bytes. Note that the returned address is in em(network
byte order). It can be converted to host byte order by the functions described
in bf(byteorder)(3).
itb(std::string dottedDecimalAddress(size_t index) const)
This member returns address `tt(index)' as a dotted decimal address in
a string. The first address has tt(index 0). If address `tt(index)' does not
exist, an empty string is returned.
itb(char const * const *endAlias() const)
This member returns an iterator pointing beyond the last alias.
itb(char const *hostname() const)
This member returns the standard (first) name of the host.
itb(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.
itb(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.
itb(void swap(Hostent &other))
The current tt(Hostent) object's content are swapped with the other
object's content.
)
manpagesection(EXAMPLE)
verb(
#include <iostream>
#include <algorithm>
#include <iterator>
#include <bobcat/hostent>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
Hostent he(gethostbyname("localhost"));
cout << "The local hostname = " << he.hostname() << endl;
cout << "All aliases: " << endl;
copy(he.beginAlias(), he.endAlias(),
ostream_iterator<char const *>(cout, "\n"));
cout << "Addresses:\n";
for (size_t idx = 0; idx < he.nAddresses(); idx++)
cout << he.dottedDecimalAddress(idx) << endl;
}
)
manpagefiles()
em(bobcat/hostent) - defines the class interface
manpageseealso()
bf(bobcat)(7)
manpagebugs()
None Reported.
includefile(include/trailer)
|