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.
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).
#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:: followed by
another fast swap to unswap their `next' pointers.
The fswap function should also not be used for objects defining
(back-)pointers to their own data. Consider the following objects using
pointers to data and (back-)pointers to the original objects:
Before fswapping:
A B
+--------+ +-----------+ +--------+ +-----------+
| | | | | | | |
+--> *Aimp------> *A (back)--+ +--> *Bimp------> *B (back)--+
| | | | | | | | | | | |
+--**Aimp | +-----------+ | +--**Bimp | +-----------+ |
+--------+ <---------------+ +--------+ <---------------+
After fswapping:
+-------------------------------+
+--|-------------------------------|-+
+-------------|--|-----------------+ | |
| A | v | B | v
| +--------+ | +-----------+ | +--------+ | +-----------+
| | | | | | | | | | | |
+-----> *Bimp---+ | *A (back)--+ +---> *Aimp---+ | *B (back)--+
| | | | | | | | | | | |
| +---**Bimp | +-----------+ | +---**Aimp | +-----------+ |
| +--------+ <---------------+ | +--------+ <---------------+
+------------------------------------+
After the swap **Bimp should point to Bimp's address (now at A),
but in fact it points to Aimp's address (now at B). Likewise, the back
pointers still point at their original objects rather than at their swapped
objects.
All stream classes