[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Issue with netconn_close() closing connection before netcon
From: |
Terry Barnaby |
Subject: |
[lwip-users] Issue with netconn_close() closing connection before netconn_write()'s have completed |
Date: |
Sat, 6 Apr 2019 06:07:04 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
I am using Lwip on an STM32F7 system along with FreeRTOS and our own
system harness ode. Lwip is generally working very well supporting a
number of TCPIP services and client functions. However we have one small
issue.
If we call netconn_close() shortly after a netconn_write() the remote
host often does not get data from the netconn_write() unless we put in a
short delay before netconn_close() is called. An example is in a simple
HTTP server like:
while(1){
// Accept any incoming connection
accept_err = netconn_accept(osocketListen, &osocket);
if(accept_err == ERR_OK){
dl4printf("Listen: accept connection\n");
netconn_set_recvtimeout(osocket, 10000);
// Serve connection
err = processRequest();
// We shouldn't need this but TCP write packets can be lost
if we don't for some reason
delayMs(1);
// Close connection
netconn_close(osocket);
// Delete connection
netconn_delete(osocket);
osocket = 0;
}
}
In this case, depending on how much is written by netconn_write(), a WEB
browser will display a window stating that the client has closed the
connection unless the 1 ms delay is included. The processRequest()
function uses netconn_recv() and netconn_write() with the flag
NETCONN_COPY. All of the netconn HTTP processing is within one thread.
I am unclear from the documentation and code if netconn_close() will
wait for the TCPIP write buffers to be sent before closing or not. I
have tried setting the lwip config option LWIP_SO_LINGER in case that
was needed but this didn't have any effect. Any info on if
netconn_close() should wait for the write buffers to be sent and if so
what config options may be needed to provide this behaviour or ideas on
what may be going wrong ?
Terry
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] Issue with netconn_close() closing connection before netconn_write()'s have completed,
Terry Barnaby <=