FBB::GetHostent

FBB::GetHostent

libbobcat1-dev_2.08.01-x.tar.gz

2005-2010


FBB::GetHostent(3bobcat)

FBB::GetHostent(3bobcat)

libbobcat1-dev_2.08.01-x.tar.gz Host information

2005-2010

NAME

FBB::GetHostent - Obtain hostent struct from hostname or -address

SYNOPSIS

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

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

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS 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

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:: 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