Other Parts Discussed in Thread: EK-TM4C1294XL
Running the pre-compiled tcpSendReceive from tirtos_tivac_2_00_01_23 on a Linux host, communicating with the TCP Echo example running on a EK-TM4C1294XL, it was found that the the tcpSendReceive host program would report a recv failure after a variable number of interations. e.g.:
The problem is the following in the tirtos_tivac_2_00_01_23/packages/examples/tools/tcpSendReceive.c source file which expects recv() to always return buffSize number of bytes:[Mr_Halfword@CentOS-Desktop ~]$ /opt/ti/ti_ccs6_0/tirtos_tivac_2_00_01_23/packages/examples/tools/tcpSendReceive 192.168.0.4 1000 1 -s100
Starting test with a 100 uSec delay between transmits
[id 1] count = 1000, time = 1
[id 1] count = 2000, time = 2
[id 1] count = 3000, time = 3
[id 1] count = 4000, time = 4
[id 1] count = 5000, time = 6
[id 1] count = 6000, time = 7
[id 1] count = 7000, time = 8
[id 1] stopping test. recv returned 512
bytes_read = recv(sockfd, buffer, buffSize, 0);
if (bytes_read != buffSize) {
printf("[id %d] stopping test. recv returned %d\n", id, bytes_read);
status = EXIT_FAILURE;
goto QUIT;
}
In fact recv returns the number of available bytes in the TCP socket (which after-all is a byte stream). i.e.
tcpSendReceive.c should be changed to call recv in a loop:
int total_bytes_read;
...
total_bytes_read = 0;
while (total_bytes_read < buffSize)
{
bytes_read = recv(sockfd, &buffer[total_bytes_read], buffSize - total_bytes_read, 0);
if (bytes_read <= 0)
{
printf("[id %d] stopping test. recv returned %d\n", id, bytes_read);
status = EXIT_FAILURE;
goto QUIT;
}
total_bytes_read += bytes_read;
}
With this change the tcpSendReceive program then ran reliably.