other versions
- wheezy 3.01.00-1+b1
- jessie 3.23.01-1
- testing 4.04.00-1
- unstable 4.04.00-1
- experimental 4.07.00-1
other sections
FBB::GetHostent(3bobcat) | Host information | FBB::GetHostent(3bobcat) |
NAME¶
FBB::GetHostent - Obtain hostent struct from hostname or -addressSYNOPSIS¶
#include <bobcat/gethostent>DESCRIPTION¶
FBB::GetHostent objects produce hostent structs which may be used by other types of objects. The FBB::GetHostent class is therefore primarily used as a base-class for other classes and is seldomly used `stand-alone’. The hostent structs are static structs, but a non-static copy may be obtained using an FBB::Hostent object. A hostent struct is defined as follows: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 address fields are binary values of the addresses, each address requiring h_length bytes, the last address being equal to 0. These binary values may be converted to character-representations by the addressToString() member, which uses inet_ntop(), internally.
NAMESPACE¶
FBBINHERITS FROM¶
-CONSTRUCTORS¶
All members of the class FBB::GetHostent are static. Consequently, there is no need to construct a FBB::GetHostent object. However, the default- and copy-constructors are available.STATIC MEMBERS¶
- o
- hostent const *gethostent(char const *errorprefix,
std::string const &nameOrAddress):
- o
- std::string addressToString(char const *errorprefix,
void const *ads):
- The class’ members can only be used when the host
whose name or address is searched can be resolved by a name resolution
process, e.g., bind(1).
EXAMPLE¶
#include <iostream> #include <algorithm> #include <iterator> #include <bobcat/hostent> #include <bobcat/gethostent> using namespace std; using namespace FBB; int main(int argc, char **argv) { if (argc == 1) { cerr << "Provide a host name or host address to solve\n"; return 1; } try { Hostent he(GetHostent::gethostent(argv[1], argv[1])); cout << "Hostname: " << he.hostname() << endl; cout << "Aliases:\n"; 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; } catch (Errno const &err) { cout << err.what() << endl; return 1; } return 0; }
FILES¶
bobcat/gethostent - defines the class interfaceSEE ALSO¶
bind(1), bobcat(7), gethostbyaddr(3) gethostbyname(3), hostent(3bobcat), inetaddress(3bobcat), inet_ntop(3)BUGS¶
None Reported.DISTRIBUTION FILES¶
- o
- bobcat_3.01.00-x.dsc: detached signature;
- o
- bobcat_3.01.00-x.tar.gz: source archive;
- o
- bobcat_3.01.00-x_i386.changes: change log;
- o
- libbobcat1_3.01.00-x_*.deb: debian package holding the libraries;
- o
- libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages;
- o
- http://sourceforge.net/projects/bobcat: public
archive location;
BOBCAT¶
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.COPYRIGHT¶
This is free software, distributed under the terms of the GNU General Public License (GPL).AUTHOR¶
Frank B. Brokken ( f.b.brokken@rug.nl).2005-2012 | libbobcat1-dev_3.01.00-x.tar.gz |