本文整理汇总了C++中ACE_INET_Addr::string_to_addr方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr::string_to_addr方法的具体用法?C++ ACE_INET_Addr::string_to_addr怎么用?C++ ACE_INET_Addr::string_to_addr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_INET_Addr
的用法示例。
在下文中一共展示了ACE_INET_Addr::string_to_addr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeviceProxy
// static
DeviceProxy *
DeviceProxy::check_hello_and_create( ACE_Message_Block * mb
, const ACE_INET_Addr& from_addr
, Task * task )
{
adportable::protocol::LifeCycleData data;
adportable::protocol::LifeCycleFrame frame;
if ( acewrapper::lifecycle_frame_serializer::unpack( mb, frame, data ) ) {
try {
using namespace adportable::protocol;
LifeCycle_Hello& hello = boost::get< LifeCycle_Hello& >(data);
ACE_INET_Addr addr;
addr.string_to_addr( hello.ipaddr_.c_str() );
if ( addr.get_ip_address() == 0 ) {
addr = from_addr;
addr.set_port_number( hello.portnumber_ );
DeviceProxy * p = new DeviceProxy( addr, task );
p->initialize_dgram();
p->handle_lifecycle_mcast( frame, data );
#if defined _DEBUG
// std::wstring key = adportable::string::convert( acewrapper::string( from_addr ) );
std::wstring text = adportable::string::convert( LifeCycleHelper::to_string( data ) );
task->dispatch_debug( text, p->name() );
#endif
return p; // error should be handled by caller
}
} catch ( std::bad_cast& ) {
}
}
return 0;
}
示例2: run_main
//.........这里部分代码省略.........
status = 1;
}
}
const char *ipv6_names[] = {
"naboo.dre.vanderbilt.edu",
"v6.ipv6-test.com",
0
};
for (int i=0; ipv6_names[i] != 0; i++)
{
ACE_INET_Addr addr (80, ipv6_names[i]);
status |= check_type_consistency (addr);
if (0 != ACE_OS::strcmp (addr.get_host_name (), ipv6_names[i]))
{
// Alias? Check lookup on the reverse.
ACE_INET_Addr alias_check;
if (alias_check.set (80, addr.get_host_name ()) == 0)
{
if (addr != alias_check)
ACE_ERROR ((LM_WARNING,
ACE_TEXT ("IPv6 name mismatch: %s (%s) != %s\n"),
addr.get_host_name (),
addr.get_host_addr (),
ipv6_names[i]));
}
else
{
ACE_ERROR ((LM_WARNING,
ACE_TEXT ("IPv6 reverse lookup mismatch: %s (%s) != %s\n"),
addr.get_host_name (),
addr.get_host_addr (),
ipv6_names[i]));
}
}
}
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 tests done\n")));
#else
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_HAS_IPV6 not set; no IPv6 tests run\n")));
#endif
struct Address loopback_addresses[] =
{ {"127.0.0.1", true}, {"127.1.2.3", true}
, {"127.0.0.0", true}, {"127.255.255.255", true}
, {"126.255.255.255", false}, {"128.0.0.0", false}, {0, true}
};
for (int i=0; loopback_addresses[i].name != 0; i++)
{
struct in_addr addrv4;
ACE_UINT32 addr32 = 0;
ACE_OS::inet_pton (AF_INET, loopback_addresses[i].name, &addrv4);
ACE_OS::memcpy (&addr32, &addrv4, sizeof (addr32));
addr.set (80, loopback_addresses[i].name);
if (addr.is_loopback() != loopback_addresses[i].loopback)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ACE_INET_Addr::is_loopback() ")
ACE_TEXT ("failed to distinguish loopback address. %C\n")
, loopback_addresses[i].name));
status = 1;
}
}
if (addr.string_to_addr ("127.0.0.1:72000", AF_INET) != -1)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ACE_INET_Addr::string_to_addr() ")
ACE_TEXT ("failed to detect port number overflow\n")));
status = 1;
}
if (!test_tao_use ())
status = 1;
if (!test_multiple ())
status = 1;
if (!test_port_assignment ())
status = 1;
ACE_INET_Addr a1 (80, "127.0.0.1");
ACE_INET_Addr a2 = a1;
if (a1 != a2)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Address equality check failed after assignment\n")));
status = 1;
}
ACE_END_TEST;
return status;
}