[ace-users] question on ACE_INET_Addr

Phil Mesnier mesnier_p at ociweb.com
Wed Aug 1 22:35:56 CDT 2007


Premkumar P wrote:
> hi,
> i tried it already but it does not work, i made a small change in 
> INET_Addr.cpp and is working now ( for now that is !!!! )
> 

Congradulations on getting it working!

I think the test for the type may be better suited inside the set 
function, otherwise it will have to be replicated throughout the class.

Steve, do you have any thoughts about a somewhat more liberal use of 
determine_type()? As Premkumar suggests, maybe in set functions that 
take an address family that can be AF_UNSPEC, and 
ACE_USES_IPV4_IPV6_MIGRATION is defined?

I think a potential problem is that some functions, such as the set 
function relied upon by the ctor modified below, are intended to let the 
OS make the IPv4/IPv6 call if AF_UNSPEC is passed as the address family.
By using determine_type() to specify AF_INET or AF_INET6, we might end 
up forcing something into an incorrect family. For example, we are 
setting up an ACE_INET_Addr to contain the address of an external host 
that really does not have IPv6, but with the local configuration, 
determine_type() returns AF_INET6, then set() will fail because the 
foreign address that should become IPv4 instead yields IPv6.

Well I'm getting tired, so I'm not thinking clearly.

> modification made :
> 
> ///////////////////////////////////////////////////////////////////////////////////////// 
> 
> 
> File : INET_Addr.cpp
> 
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 
> ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
>                               const char host_name[],
>                               int address_family)
>   : ACE_Addr (determine_type (), sizeof (inet_addr_))
> {
>   ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
>   ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
>   if (this->set (port_number,
>                  host_name,
>                  1,
>                  address_family)  == -1)
>     ACE_ERROR ((LM_ERROR,
>                 ACE_LIB_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"),
>                 ACE_TEXT_CHAR_TO_TCHAR ((host_name == 0) ?
>                                         "<unknown>" : host_name)));
> }
> 
>  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> ACE_INET_Addr::ACE_INET_Addr (u_short port_number,
>                               const char host_name[],
>                               int address_family)
>   : ACE_Addr (determine_type (), sizeof (inet_addr_))
> {
>   ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
>   ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
>   if (this->set (port_number,
>                  host_name,
>                  1,
>                  (address_family == 0 ? get_type() : address_family)) == -1)
>     ACE_ERROR ((LM_ERROR,
>                 ACE_LIB_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"),
>                 ACE_TEXT_CHAR_TO_TCHAR ((host_name == 0) ?
>                                         "<unknown>" : host_name)));
> }
> 
> /////////////////////////////////////////////////////////////////////////////////////////
> 
> 
> it is determining the type type properly in the constructory entry but 
> the set function when called with address_family set to 0 will set the 
> type to AF_INET6, i used the the guessed type if the address_family is 
> not specified.
> 
> 
> if this is not the right place to make the modficiation please let me know
> 
> thankx in advance,
> Prem
> 
> 
> On 8/2/07, *Phil Mesnier* < mesnier_p at ociweb.com 
> <mailto:mesnier_p at ociweb.com>> wrote:
> 
> 
> 
>     Premkumar P wrote:
>      > hi,
>      > thankx for the reply
>      > i found ACE_USES_IPV4_IPV6_MIGRATION being used in ACE_INET_Addr to
>      > guess if ipv6 works or not and then set the type properly will
>     this help ??
>      >
> 
>     Yes, I had forgotten about that switch. #define that in your config.h
>     and rebuild.
> 
>     --
>     Phil Mesnier
>     Principal Software Engineer,    http://www.ociweb.com
>     Object Computing, Inc.          +01.314.579.0066
> 
> 

-- 
Phil Mesnier
Principal Software Engineer,    http://www.ociweb.com
Object Computing, Inc.          +01.314.579.0066



More information about the Ace-users mailing list