Skip to content

Allocating memory at run time

jeevan mummadi

Asked May 8, 2008, 1:21 AM EDT1 answer
Share
LinkedInX

hello,  i have declared byte[] at runtime by allocating some memory.(socket programming)

     

C#
public void OnDataReceived(IAsyncResult asyn)
{


CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState;
try
{
int iRx = 0;
conn_arr = "*0001";
conn_arr1 = "*0001#\0";
//iRx = theSockId.thisSocket.EndReceive(asyn);
iRx = theSockId.m_currentSocket.EndReceive(asyn);
byte[] power = new byte[iRx] ;
--
--
--
}

-> power is getting allocated for 1024 bytes,but i want to allocate only for the no of bytes received(iRx).

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    Why you didn't use the memory stream object
    0