本文整理汇总了C++中TInetAddr::IsLoopback方法的典型用法代码示例。如果您正苦于以下问题:C++ TInetAddr::IsLoopback方法的具体用法?C++ TInetAddr::IsLoopback怎么用?C++ TInetAddr::IsLoopback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInetAddr
的用法示例。
在下文中一共展示了TInetAddr::IsLoopback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckAndSetAddr
// -----------------------------------------------------------------------------
// CLocalAddrResolver::CheckAndSetAddr
// -----------------------------------------------------------------------------
//
void CLocalAddrResolver::CheckAndSetAddr( TInetAddr& aTarget,
TInetAddr& aCandidate,
TUint32 aCandidateIap,
TUint32 aSpecifiedIap )
{
if ( !aCandidate.IsUnspecified() && !aCandidate.IsLoopback() )
{
if ( aCandidate.IsV4Mapped())
{
aCandidate.ConvertToV4();
}
if ( aCandidateIap == aSpecifiedIap )
{
SetAddr( aTarget, aCandidate );
}
}
}
示例2: ListInterfacesL
//.........这里部分代码省略.........
HBufC8 *buffer =NULL;
buffer = GetBuffer(buffer, bufsize);
TESTL(buffer != NULL);
TPtr8 bufdes = buffer->Des();
//-- reset array of local addresses
ipTestServer->iLocalAddrs.Reset();
//-- list all available network interfaces
INFO_PRINTF1(KNewLine);
INFO_PRINTF1(_L("--- available network interfaces:"));
do
{//-- get list of network interfaces
// if exceed>0, all interface could not fit into the buffer.
// In that case allocate a bigger buffer and retry.
// There should be no reason for this while loop to take more than 2 rounds.
bufdes.Set(buffer->Des());
exceed = socket.GetOpt(KSoInetInterfaceInfo, KSolInetIfQuery, bufdes);
if(exceed > 0)
{
bufsize += exceed * sizeof(TInetInterfaceInfo);
buffer = GetBuffer(buffer, bufsize);
TESTL(buffer != NULL);
}
} while (exceed > 0);
if (exceed < 0)
{
INFO_PRINTF1(_L("socket.GetOpt() error!"));
TESTL(EFalse);
}
TOverlayArray<TInetInterfaceInfo> infoIface(bufdes);
for(idx=0; idx < infoIface.Length(); ++idx)
{
TInetInterfaceInfo& iface = infoIface[idx];
tmpBuf.Format(_L("index:%d, name: "),iface.iIndex);
tmpBuf.Append(iface.iName );
tmpBuf.AppendFormat(_L(" state:%d"), iface.iState);
INFO_PRINTF1(tmpBuf);
}
//-- list all IP addresses, bound to the interfaces
//-- and append this address to the array of host-local addresses
INFO_PRINTF1(KNewLine);
INFO_PRINTF1(_L("--- IP addresses bound to the interfaces:"));
do
{
// if exceed>0, all interface could not fit into the buffer.
// In that case allocate a bigger buffer and retry.
// There should be no reason for this while loop to take more than 2 rounds.
bufdes.Set(buffer->Des());
exceed = socket.GetOpt(KSoInetAddressInfo, KSolInetIfQuery, bufdes);
if(exceed > 0)
{
bufsize += exceed * sizeof(TInetAddressInfo);
buffer = GetBuffer(buffer, bufsize);
}
} while (exceed > 0);
if (exceed < 0)
{
INFO_PRINTF1(_L("socket.GetOpt() error!"));
TESTL(EFalse);
}
//-- print out IP addresses
TOverlayArray<TInetAddressInfo> infoAddr(bufdes);
TInetAddr inetAddr;
for(idx=0; idx < infoAddr.Length(); ++idx)
{
TInetAddressInfo& addr = infoAddr[idx];
tmpBuf.Format(_L("iface index: %d, scopeID: %d, state: %d, IP addr: "), addr.iInterface, addr.iScopeId, addr.iState);
inetAddr.SetAddress(addr.iAddress);
inetAddr.Output(tmpBuf1);
tmpBuf.Append(tmpBuf1);
INFO_PRINTF1(tmpBuf);
//-- if obtained IP address is valid and not loopback, add it to the array.
if(inetAddr.IsLoopback() || inetAddr.IsUnspecified())
{}
else
ipTestServer->iLocalAddrs.Append(inetAddr);
}
delete buffer;
socket.Close();
INFO_PRINTF1(KNewLine);
}