[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Issue with netconn_close closing connection before netc

From: Terry Barnaby
Subject: Re: [lwip-users] Issue with netconn_close closing connection before netconn_write's have completed
Date: Sat, 4 May 2019 12:26:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

No one have any ideas on this ?

On 19/04/2019 11:17, Terry Barnaby wrote:
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:

        // 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

            // Close connection

            // Delete connection
            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 ?

lwip-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]