bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

InetAddress classes


From: Marc Boris Dürner
Subject: InetAddress classes
Date: Sat, 27 Dec 2003 01:06:48 +0100 (MET)

Hi, 
I am looking at the InetAddress class and the derived ones right now.  
 
- shouldnt (or could?) the gethostname stuff be in a class Resolver? That
way resolving 
and raw IP handling would be separated. Does this make sense?  
 
- I need a function to get a string representation of the ip address
(in_addr to string) 
something along the lines of: 
 
std::string InetAddress::str() const { 
        union addr_u { 
        uint32_t dword; 
        uint8_t bytes[4]; 
        } a; 
        a.dword = ipaddr[0].s_addr; 
 
        std::stringstream addrstr; 
        for(int n = 0; n < 3; ++n) { 
                addrstr << std::dec << (int)a.bytes[n] << "."; 
        } 
        addrstr << std::dec << (int)a.bytes[3]; 
        return addrstr.str(); 
} 
 
 
- Is anything speaking against making InetAddress a template where the
validator is the 
template type? 
 
regards, 
Marc 
 

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net






reply via email to

[Prev in Thread] Current Thread [Next in Thread]