Hi, I have a problem to create socket in a sub task, which is created in one of my task by calling TaskCreate. the following code shows the way how my code is organized.
void myNdkTask() //this task is created statically in the .cfg file
{
..............
SOCKET s;
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(s == INVALID_SOCKET)
{
if(debug)
printf("failed create socket (%d)\n", fdError());
exit(1);
}
..............
void (*pTaskFxn)(int, int, int);
pTaskFxn=subTaskFxn;
TaskCreate(pTaskFxn, "subtask0", OS_TASKPRINORM, 2048, 0, 0, 0);
}
void subTaskFxn{}
{
..............
SOCKET sub_socket;
sub_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sub_socket == INVALID_SOCKET)
{
if(debug)
printf("failed create socket (%d)\n", fdError());
exit(1);
}
..................
}
when the program is executed, it always exit because of the fail of creating sub_socket, but the SOCKET s in myNdkTask() can return a VALID handle. can anyone helps me solve it or points out the problem that I have not noticed? thanks