Tool/software: TI-RTOS
I have been trying to debug a problem with the TCP sockets that appears as if they are not blocking.
To pin the problem down I reinstalled TI-RTOS 2.16.1.14 and imported the tcpEcho demo and made minimal modifications to reproduce the problem.
Notice the actual demo program runs in an infinite loop returning 0 bytes consuming the available CPU cycles until data is on the socket. BSD sockets (which it is using) are supposed to block until there is data on the socket, a timeout occurs, or error (with errno set). To reproduce the problem I modified the tcpWorker() subroutine as follows:
Void tcpWorker(UArg arg0, UArg arg1) {
int clientfd = (int)arg0;
int bytesRcvd;
int bytesSent;
char buffer[TCPPACKETSIZE];
int notdone = true;
System_printf("tcpWorker: start clientfd = 0x%x\n", clientfd);
while (notdone) {
// should block until TCPPACKETSIZE bytes are received or error.
bytesRcvd = recv(clientfd, buffer, TCPPACKETSIZE, MSG_WAITALL);
System_printf ("received %d bytes. errno = %d.\n", bytesRcvd, errno);
System_flush ();
bytesSent = send(clientfd, buffer, bytesRcvd, 0);
if (bytesSent < 0 || bytesSent != bytesRcvd) {
System_printf("Error: send failed.\n");
break;
}
}
System_printf("tcpWorker stop clientfd = 0x%x\n", clientfd);
System_flush();
close(clientfd);
}
Notice even when I specified MSG_WAITALL (I tried without as well) that recv() continues to return 0 bytes with no errno set.
I tried reporting the problem before but didn't get any useful responses so I am trying again.
Thanks,
- Gary Brack
