I am working on a simple TCP server where multiple client will connect to it. The requirement was server will have multiple port and on each port we will connect the client. so a dedicated connection will be establish.
Now the code i have written works fine. but when
/* Create a task to look after it */
if (RTCS_detachsock(child_sock) == RTCS_OK)
{
result = _task_create(0, SERVER_C_TASK_0, child_sock);
if (result == MQX_NULL_TASK_ID)
{
RTCS_attachsock(child_sock);
shutdown(child_sock, FLAG_CLOSE_TX);
printf("\nCould not create server child task.\n\r");
}
}
else
{
printf("\n accept() failed, error 0x%lx", RTCS_geterror(child_sock));
}
on excecution of the underline statement. i see output on terminal:
I'm waiting for connections ...
Error, accept() failed with error code 1704
Error, getpeername() failed with error code 1704
Client 0 is already connected.
now i am not able to decode the error code 1704.
like what exactly it meant. and what action should i take to avoid it.
Solved! Go to Solution.
thanks Martin, this information is very useful....thanks again...
:smileyhappy:
Hi,
RTCS related error codes are defined in rtcs.h
c:\Freescale\Freescale_MQX_4_0\rtcs\source\include\rtcs.h
RTCS_ERROR_BASE is defined in mqx.h 0x1000
c:\Freescale\Freescale_MQX_4_0\mqx\source\include\mqx.h
so in rtcs.h, for 0x1704 = RTCS_ERROR_BASE | 0x704 = RTCSERR_SOCK_INVALID
Seems the child_sock is not valid.
thanks Martin, this information is very useful....thanks again...
:smileyhappy:
With the error decoding, i figure out that the sockets i initialized while initializing the network was lower than what i was using....increasing the socket has solved the problem.