当前位置: 首页>>代码示例>>C++>>正文


C++ TPtr8::Repeat方法代码示例

本文整理汇总了C++中TPtr8::Repeat方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtr8::Repeat方法的具体用法?C++ TPtr8::Repeat怎么用?C++ TPtr8::Repeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TPtr8的用法示例。


在下文中一共展示了TPtr8::Repeat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doTestStepL

enum TVerdict CTS_CEsockSendAndRecvData::doTestStepL( void )
	{
	TRequestStatus stat, stat2;
	TBuf8<50> Data;

	// Qos Channel(s)
	for (TInt i = 0;i < iQoSSuite->iQoSChannel.Count();i++)
		{
		// Socket(s)
		for (TInt i2 = 0;i2 < iQoSSuite->iQoSChannel[i]->GetSocketListCount() ;i2++)
			{
			// set up data buffers
			HBufC8 * writebuf = HBufC8::NewMaxLC( iQoSSuite->iQoSChannel[i]->iPacketSize[i2] );
			HBufC8 * readbuf  = HBufC8::NewMaxLC( iQoSSuite->iQoSChannel[i]->iPacketSize[i2] );
			TPtr8 ptrWritebuf = writebuf->Des();
			TPtr8 ptrReadbuf = readbuf->Des();

			TInt recvCount = 0;

			Log( _L("QoS Channel <%d>, Socket <%d>"), i+1, i2+1);

			// Send / Recv TCP
			if (iQoSSuite->iQoSChannel[i]->iProtocol[i2] == KProtocolInetTcp)
				{
				Log( _L("Sending TCP data, %d packets of %d bytes = %d"), 
				iQoSSuite->iQoSChannel[i]->iPackets[i2], iQoSSuite->iQoSChannel[i]->iPacketSize[i2], iQoSSuite->iQoSChannel[i]->iPackets[i2] * iQoSSuite->iQoSChannel[i]->iPacketSize[i2]);
				
				// Number of Packets to Send / Recv
				for (TInt i4 = 0; i4 < iQoSSuite->iQoSChannel[i]->iPackets[i2]; i4++)
					{
					// initialise data
					Data.Format(_L8("TCP-packet:%d helloworld"),i4);
					ptrWritebuf.Repeat( Data );

					// write data
					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->Write(ptrWritebuf, stat);
					User::WaitForRequest(stat);
					TESTL(stat==KErrNone);

					// read data
					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->Read(ptrReadbuf, stat);
					User::WaitForRequest(stat);
					TESTL(stat==KErrNone);

					// compare the data
					TESTL( ptrWritebuf.Compare( ptrReadbuf ) == 0);
					recvCount+=ptrReadbuf.Length();
					}
				//	writebuf and readbuf
				CleanupStack::PopAndDestroy(2);	
				} 

			// Send / Recv UDP
			if (iQoSSuite->iQoSChannel[i]->iProtocol[i2] == KProtocolInetUdp)
				{
				Log( _L("Send Udp Data, %d packets of %d bytes = %d"), 
				iQoSSuite->iQoSChannel[i]->iPackets[i2], iQoSSuite->iQoSChannel[i]->iPacketSize[i2], iQoSSuite->iQoSChannel[i]->iPackets[i2] * iQoSSuite->iQoSChannel[i]->iPacketSize[i2]);

				// Number of Packets to Send / Recv
				for (TInt i4 = 0; i4 < iQoSSuite->iQoSChannel[i]->iPackets[i2]; i4++)
					{
					// initialise data
					Data.Format(_L8("UDP-packet:%d helloworld"),i4);
					ptrWritebuf.Repeat( Data );

					// write data 
					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->SendTo(ptrWritebuf, iQoSSuite->iQoSChannel[i]->iDestAddr[i2], 0, stat);
					User::WaitForRequest(stat);
					TESTL(stat==KErrNone);

					iQoSSuite->iQoSChannel[i]->GetSocketHandle(i2)->RecvFrom(ptrReadbuf, iQoSSuite->iQoSChannel[i]->iDestAddr[i2], 0, stat2);
					User::WaitForRequest(stat2);
					TESTL(stat==KErrNone);

					// compare the data
				  	TESTL( ptrWritebuf.Compare( ptrReadbuf ) == 0 );
					recvCount += ptrReadbuf.Length();
					}
				//	writebuf and readbuf
				CleanupStack::PopAndDestroy(2);
				}

			// check the total received (95 per cent is allowable for us)
			TESTL(recvCount*iQoSSuite->iQoSChannel[i]->iPacketSize[i2] > (0.95*(iQoSSuite->iQoSChannel[i]->iPackets[i2]*iQoSSuite->iQoSChannel[i]->iPacketSize[i2])) );	
			}		
		}

	return EPass;
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:89,代码来源:TS_QoSSocketSection.cpp

示例2: SendAndRecvL

void CMultipleArray::SendAndRecvL(TInt aExtraSocksToJoin)
	{
	TRequestStatus stat;
	TBuf8<50> Data;

	// set up data buffers
	HBufC8 * writebuf = HBufC8::NewMaxLC( iPacketSize[aExtraSocksToJoin] );
	HBufC8 * readbuf  = HBufC8::NewMaxLC( iPacketSize[aExtraSocksToJoin] );
	TPtr8 ptrWritebuf = writebuf->Des();
	TPtr8 ptrReadbuf = readbuf->Des();

	TInt recvCount = 0;

	// Send / Recv TCP
	if (iProtocol[aExtraSocksToJoin] == KProtocolInetTcp)
		{
		for (TInt i = 0; i < iPackets[aExtraSocksToJoin]; i++)
			{
			iQoSStep->iQoSSuite->Log( _L("Sending TCP data, %d packets of %d bytes = %d"), 
			iPackets[aExtraSocksToJoin], iPacketSize[aExtraSocksToJoin], iPackets[aExtraSocksToJoin] * iPacketSize[aExtraSocksToJoin]);

			// initialise data
			Data.Format(_L8("TCP-packet:%d helloworld"),i);
			ptrWritebuf.Repeat( Data );

			// write data
			GetSocketHandle(aExtraSocksToJoin)->Write(ptrWritebuf, stat);
			User::WaitForRequest(stat);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to write tcp data to destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			// read data
			GetSocketHandle(aExtraSocksToJoin)->Read(ptrReadbuf, stat);
			User::WaitForRequest(stat); //, TimerStatus);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to read tcp data from destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			// compare the data
			if (ptrWritebuf.Compare( ptrReadbuf ) != 0)
				{
				iQoSStep->iQoSSuite->Log(_L("Data written to and read from destination address do not match in size"));
//				return Fail;
				}

			recvCount+=ptrReadbuf.Length();
			}

		CleanupStack::PopAndDestroy(2);	//	writebuf and readbuf
		} 

	// Send / Recv UDP 
	if (iProtocol[aExtraSocksToJoin] == KProtocolInetUdp)
		{
		iQoSStep->iQoSSuite->Log( _L("Send Udp Data, %d packets of %d bytes = %d"), 
		iPackets[aExtraSocksToJoin], iPacketSize[aExtraSocksToJoin], iPackets[aExtraSocksToJoin] * iPacketSize[aExtraSocksToJoin]);
	
		for (TInt i = 0; i < iPackets[aExtraSocksToJoin]; i++)
			{
			// initialise data
			Data.Format(_L8("UDP-packet:%d helloworld"),i);
			ptrWritebuf.Repeat( Data );	

			// write data
			GetSocketHandle(aExtraSocksToJoin)->Send(ptrWritebuf, 0, stat);
			User::WaitForRequest(stat);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to write udp data to destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			GetSocketHandle(aExtraSocksToJoin)->Recv(ptrReadbuf, 0, stat);
			User::WaitForRequest(stat);
			if (stat!=KErrNone)
				{
				iQoSStep->iQoSSuite->Log(_L("Failed to read udp data from destination: return value = <%d>"), stat);
				User::Leave(stat.Int());
				}

			// compare the data
			if (ptrWritebuf.Compare( ptrReadbuf ) != 0 )
				{
				iQoSStep->iQoSSuite->Log(_L("Data written to and read from destination address do not match in sizevalue"));
//				return Fail;
				}
			recvCount += ptrReadbuf.Length();
			}

		// get rid of the old buffers 
		CleanupStack::PopAndDestroy(2);	//	writebuf and readbuf
		}


	// check the total received (95 per cent is allowable for us)
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,代码来源:CMultipleArray.cpp


注:本文中的TPtr8::Repeat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。