Dear Sir:
I have a problem when using NDK2.0.0 in my project.
CCS Version : Code Composer Studio 4.2.0.10018
Target CPU : TMS320C6747
Reference examples: NDK2.0.0\ti\ndk\example\network\client\evm6747\client.pjt
The DSP is connected to a PHY(act as a client) to communicate with the PC (act as a sever).
When I'm sending data in an infinite loop,after a few seconds , the programme run to a function called UTL_HALT().
What's the meaning and how to avoid the problem appears?
**** My program is following(Modified at conecho.c):***********************************
void MyEchoTcp()
{
SOCKET s;
struct sockaddr_in sin1;
char *pBuf = 0;
Int16 sendbytes;
int error = 0,status,size;
printf("\n== Start My TCP Echo Client Test ==\n");
/* Allocate the file environment for this task */
fdOpenSession( TaskSelf() );
if( !(pBuf = mmBulkAlloc( 1024 )) )
{
printf("failed allocate buffer ,leaving...\n");
goto leave;
}
s = socket(AF_INET, SOCK_STREAMNC, IPPROTO_TCP);
if( s == INVALID_SOCKET )
{
printf("failed socket create (%d),leaving...\n",fdError());
goto leave;
}
// Prepare address for connect
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_len = sizeof( sin1 );
sin1.sin_addr.s_addr = 0xDD00A8C0;//IPAddr;
sin1.sin_port = htons(5908);
// Configure our Tx and Rx timeout to be 5 seconds
timeout.tv_sec = 5;
timeout.tv_usec = 0;
setsockopt( s , SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) );
setsockopt( s , SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
SocketValid = 0;
while(1)
{
// Connect socket
if ( connect( s, (PSA) &sin1, sizeof(sin1) ) < 0 )
{
LOG_printf(&myLog,"failed connect s (%d)\n",fdError());
LOG_printf(&myLog,"connect task sleep 2 s ... \n");
TaskSleep(2000);
continue;
}
SocketValid = 1;
while(SocketValid)
{
sendbytes = send( s, pBuf, 1024, 0 );//Line A
if( sendbytes < 0 )
{
LOG_printf(&myLog, "Failed sendto : (%d)\n",fdError());
switch(fdError())
{
case ENOTCONN:
SocketValid = 0;
break;
}
}
else
{
LOG_printf(&myLog, "Success send Bytes:(%d)",sendbytes);
TaskSleep(1);//Line B
}
}
}
leave:
if( pBuf )
mmBulkFree( pBuf );
fdCloseSession( TaskSelf() );
printf("== socket task end ==\n\n");
TaskExit();
}
******************************************************************************************
I have tried to modify some value in this program and get a few rules,that is
1. sendbytes = send( s, pBuf, N, 0 );//Line A, the program run to UTL_HALT() more quickly when N increase;
2. TaskSleep(N)//Line B,the program run to UTL_HALT() more quickly when N reduce;
3. When I set a breakpoint at Line A and sending 1024 bytes each time,when the program run to the breakpoint after 8 times,the program will run to UTL_HALT().
In my view,it seems that this problem has some relation to the TCP Transmit buffer size(the default size is 8192),Am I true?
Please give me some suggestions,thank you!