Hello,
I am having problems of simultaneous reading and writing to a TCP socket with LwIP, FreeRTOS, AVR32 (EWK1100).
I know that lwip_write() and lwip_read() calls are not threadsafe and I have seen a lot of other forum threads discussing this and the use semaphores of lwip_select(). - I do not think this is the problem here.
I have boiled down my program to only have one thread with one lwip_write() call and one delay of app. 1msec. (No lwip_read() call !). (See source code below.)
When I connect a terminal program from a PC, it will start receiving the messages. When sending a few messages (Just pressing ENTER) from the terminal program to the AVR32, it will make the transmission from the AVR pause for exactly 10 sec. - Then resume. this can be repeated a number of time whereafter transmission completely stops.
I have traced down the 10sec pause to be in api_lib.c, netconn_write(), sys_mbox_fetch(conn->mbox, NULL); call.
A WireShark recording is attached. The problem appear at time: 20.147 and again at 34.903.LwIP_ReadWrite.pcapng
Anyone knows of a fix, that can make the system keep transmitting messages while other messages are being transmitted in the other direction ?
Thank you.
Source code:
static portTASK_FUNCTION( shellTask, pvParameters )
{
int sock, sock2, status, j;
struct sockaddr_in sockAddr;
sockAddr.sin_family = AF_INET;
sockAddr.sin_len = sizeof(sockAddr);
sockAddr.sin_port = htons(6001);
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sock = lwip_socket (AF_INET, SOCK_STREAM, 0);
lwip_bind (sock, (struct sockaddr*) &sockAddr, sizeof(struct sockaddr_in));
lwip_listen (sock, 1);
sock2 = lwip_accept (sock, (struct sockaddr*) &sockAddr, &status);
while (1)
{
lwip_write(sock2, "Hello\r", 6);
for (j=0; j < 10000;j++);
}
}
Sent from the lwip-users mailing list archive at Nabble.com.