Hi,
I am trying to using the NDK for the networking in my project. Run on TMDSEVM6678LE.
Here are my steps:
1. Just modified HUA project's TCP_perform_receive() in ndkbenchmark.c and create my own thread(Fragment code of the modified TCP_perform_receive() as below), executed in NetworkOpen().
hTCP_perform_receive = TaskCreate(TCP_perform_receive, "TCPBenchmarkRX", OS_TASKPRIHIGH, 0x3000, 0, 0, 0);
2. The "FD_SETSIZE" adjusted from 16 to 127.
3. Modified *.cfg file, Program.sectMap[".far:NDK_PACKETMEM"]= {loadSegment: "MSMCSRAM", loadAlign: 128}; /* NDK Buffer Pool */
Program.sectMap[".far:NDK_MMBUFFER"]= {loadSegment: "MSMCSRAM", loadAlign: 128};
Global.pbmDataSection = ".far:NDK_PACKETMEM";
Global.memDataSection = ".far:NDK_MMBUFFER";
FD_SET(stcp, master);
max_fd = (INT32)stcp;
for(;;){
/*** Handle TCP new connection ***/
ibits = master;
tmp = fdSelect(max_fd + 1, &ibits, NULL, &xbits, &timeout);
if(tmp < 0){ break; }
if(FD_ISSET(stcp, &ibits)){
size = sizeof(sin1);
bzero( &sin1, sizeof(struct sockaddr_in) );
stcp_child = accept(stcp, (PSA)&sin1, &size);
if (stcp_child != INVALID_SOCKET){
for(count = 0; count < USER_MAX_NUM; count++){
if(UserData[count].stcp_child == INVALID_SOCKET){
UserData[count].stcp_child = stcp_child;
User_Count++;
FD_SET(stcp_child, &slave);
if((INT32)stcp_child > max_fd){ max_fd = (INT32)stcp_child; }
stcp_child = INVALID_SOCKET;
break;
}
}
}else{
platform_write("Failed accept due to error: %d \n", fdError());
goto leave;
}
}
...
}
After complied, I observed the spread memory of NDK in *.map as below:
run origin load origin length init length attrs members
---------- ----------- ---------- ----------- ----- -------
0c000000 0c000000 001a98c0 00000000 rw-
0c000000 0c000000 0019d700 00000000 rw- .far:NDK_PACKETMEM
0c19d700 0c19d700 0000c1c0 00000000 rw- .far:NDK_MMBUFFER
Tested by our own PC side client program to connect with server (DSP), the connection's number lower than 53 looks fine.
But if the number more than 53 (even more number), it can't connected with server not any longer. Why?
The Screenshots as show below:
... ...
My guess is that the length (0xC1C0) of NDK_MMBUFFER may be not enough to handle more than 53 connnection.
But I don't know how to increase this buffer size, is it right? How can I resolve this problem?
Your help is much appreciated.