diff -r a03f92240627 -r 33016869e0dd hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CProtocolUDP.cpp --- a/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CProtocolUDP.cpp Tue Feb 02 01:57:15 2010 +0200 +++ b/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CProtocolUDP.cpp Fri Apr 16 16:37:27 2010 +0300 @@ -132,22 +132,42 @@ "CProtocolUDP::WriteFrameL(), peer port=%d, original port=%d" ), aPeerPort, aOriginalPort ); - aSocketWriter.WriteL( KUDPPrefix ); - - TBuf8 portBuf; - portBuf.Format( KHexFormat, aPeerPort ); - aSocketWriter.WriteL( portBuf ); - aSocketWriter.WriteL( KPortSuffix ); + TInt bufSize = 0; + bufSize += KUDPPrefix().Length(); + bufSize += KHexDecimalLength; + bufSize += KPortSuffix().Length(); + bufSize += KHexDecimalLength; + bufSize += KLengthSuffix().Length(); + bufSize += aData.Length(); + bufSize += KDataSuffix().Length(); + bufSize += KMessageSuffix().Length(); + + TBuf8 hexbuf; + HBufC8* buf = HBufC8::NewLC( bufSize ); + TPtr8 ptr( buf->Des() ); + + // Append UDP prefix + ptr.Append( KUDPPrefix ); - TBuf8 lengthBuf; - lengthBuf.Format( KHexFormat, aData.Length() ); - aSocketWriter.WriteL( lengthBuf ); + // Append peer port + hexbuf.Format( KHexFormat, aPeerPort ); + ptr.Append( hexbuf ); + ptr.Append( KPortSuffix ); + + // Append data length + hexbuf.Format( KHexFormat, aData.Length() ); + ptr.Append( hexbuf ); + ptr.Append( KLengthSuffix ); - aSocketWriter.WriteL( KLengthSuffix ); - aSocketWriter.WriteL( aData ); - aSocketWriter.WriteL( KDataSuffix ); + // Append data + ptr.Append( aData ); + ptr.Append( KDataSuffix ); + ptr.Append( KMessageSuffix ); + + // Write to socket + aSocketWriter.WriteL( *buf ); - aSocketWriter.WriteL( KMessageSuffix ); + CleanupStack::PopAndDestroy( buf ); } // -----------------------------------------------------------------------------