本文整理汇总了C++中TName::AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ TName::AppendFormat方法的具体用法?C++ TName::AppendFormat怎么用?C++ TName::AppendFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TName
的用法示例。
在下文中一共展示了TName::AppendFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoConnect
TInt RConsoleProxy::DoConnect(TServerParams* aParams, const TDesC& aThreadNameBase, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, RServer2& aServer, RThread& aServerThread)
{
TName threadName;
RThread server;
TInt threadId = 0;
_LIT(KThreadIdFmt, "%08x");
TInt err;
do
{
threadName = aThreadNameBase.Left(threadName.MaxLength()-8);
threadName.AppendFormat(KThreadIdFmt, threadId);
err = server.Create(threadName, &ServerThreadFunction, aStackSize, aHeapMinSize, aHeapMaxSize, aParams);
++threadId;
} while (err==KErrAlreadyExists);
if (err!=KErrNone) return err;
TRequestStatus rendezvous;
server.Rendezvous(rendezvous);
if (rendezvous == KRequestPending)
{
server.Resume();
}
User::WaitForRequest(rendezvous);
err = rendezvous.Int();
if (server.ExitType() != EExitPending && err >= 0) err = KErrDied;
if (err==KErrNone)
{
err = Connect(aParams->iServer);
}
aServer = aParams->iServer;
aServerThread = server;
return err;
}
示例2: ListInterfacesL
/**
* List existing network interfaces, IP addresses bound to them
* and fill up array of IP addresses for all interfaces.
*/
void CTestStepLLMNR_Init::ListInterfacesL()
{
RSocket socket;
TInt nRes;
TInt exceed;
TInt idx;
TName tmpBuf;
TName tmpBuf1;
nRes = socket.Open(ipTestServer->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp);
TESTL(nRes == KErrNone);
TUint bufsize = 2048;
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);
//.........这里部分代码省略.........