#ifndef INCLUDED_BOBCAT_INETADDRESS_
#define INCLUDED_BOBCAT_INETADDRESS_

#include <netinet/in.h>
#include <string>

/*
    int-info coming in or going out: host byte order
*/    
namespace FBB
{

class InetAddress
{
    sockaddr_in     d_address;  // address/port: network byte order
                            // sa_family_t  in_addr,    uint16_t
                            // sin_family,  sin_addr,   sin_port
    public:
        uint16_t port() const;                                      // .f

            // replaces the formerly available getAddress() member.
        std::string dottedDecimalAddress() const;
        sockaddr const *sockaddrPtr() const;                        // 1.f
        sockaddr_in const *sockaddr_inPtr() const;                  // 1.f
        size_t size() const;                                        //  .f

    protected:
        InetAddress(std::string const &host, uint16_t port);
        explicit InetAddress(uint16_t port);                    // 1.f
        explicit InetAddress(sockaddr_in const &address);       // 2.f

        sockaddr *sockaddrPtr();                                // 2.f
        sockaddr_in *sockaddr_inPtr();                          // 2.f

    private:
        void init(uint32_t addr, uint16_t port);    // host byte order !
};

#include "inetaddress1.f"
#include "inetaddress2.f"
#include "port.f"
#include "size.f"
#include "sockaddrinptr1.f"
#include "sockaddrinptr2.f"
#include "sockaddrptr1.f"
#include "sockaddrptr2.f"

} // FBB

#endif
