I'm using CW 10.2, MQX 3.8.1 and a custom board based on Kinetis K60.
Basically I have 2 tasks task_a that creates task_b:
_task_create( ... task_b ... );
_task_abort( ... task_b ... );
sock1 = socket( AF_INET, SOCK_STREAM, 0 );
if( bind( sock1, ... ) != RTCS_OK )
if( listen( sock1, 0 ) != RTCS_OK )
sock2 = accept( sock1, ... );
When task_b is executed, it creates a socket (sock1) and waits for a connection, blocking itself inside the accept() function. If no connection is made task_b waits infinitely, so sock2 is not assigned. When task_a must close task_b, the sockets created by task_b must be closed. The problem is that sock1 is assigned, but sock2 is already unassigned, but the function accept(), before blocking, has allocated the socket structure that is normally released by closing the socket.
How can I correctly close the socket?