This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Network cannot receive large amounts of data

I use VC6.0 write a program to send 20 MB data to 6678EVM. But it is only about 16MB of data received and an error occurred. I have tried many times and the recv () function returns a value of 0 or -1.Test result when I only send and receive data 10MB is correct.I  use the TCP protocol.And NDK settings are configured in accordance with routine.

DSP-side part of the program are as follows:

to.tv_sec = 4;
to.tv_usec = 0;
setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) );
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) );

i = 1;
setsockopt( s, IPPROTO_TCP, TCP_NOPUSH, &i, 4 );

while(1)
{
  i = (int)recv( s, &length, sizeof(int), 0);
  count = 0;

if(length > 0)
{
while( count < 1024*1024*20 )
{
i = (int)recv( s, (TcpRcvData+count), 1024*1024*20, 0);
if(i > 0)
count += i;
}

count = 0;
length = 0;
}
}

VC-side part of the program are as follows:

Send((char*)pBuff,1024*1024*20,0);

  • Hi,

    Can you share full code of TCP task? Please check the below code, it is not yet tested.

    #define PKTSZ          (1460)
    #define NUMPACKETS      (20*1024*1024)  
    int cnt =0;
     
    cnt = (int)recv( s, (char *)TcpRcvData, PKTSZ, 0 );
    
    for(i=0; i<NUMPACKETS-1; i++)
    {
     TcpRcvData = (char *)TcpRcvData + cnt;
     cnt  = (int)recv( s, (char *)TcpRcvData, PKTSZ, 0 );
    }