lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] How to detect a FIN from the remote side


From: Marco Jakobs
Subject: [lwip-users] How to detect a FIN from the remote side
Date: Mon, 07 Dec 2009 15:41:09 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Hi,

i'm acting as a MODBUS/TCP server and discovered a problem with a test application using a TCP connection. As my IP server task handles several protocols, i'm using the lwIP API with a timeout criteria for the receive function:

            modsrvbuf=0;
            modsrvsession->recv_timeout=1;    // Set timeout to 1ms
            modsrvbuf=netconn_recv(modsrvsession);    //Receive data (if some are there)
            if (modsrvbuf!=0)        // Buffer was assigned (there were some data
            {
                ... process incoming data

This works perfectly.

But one of my test programs only sends a FIN when i choose there to close the connection. With this, lwIP does not detect a connection close for the TCP (this is OK, because a remote FIN does not close the TCP connection). But now my connection is stuck in the open state.

My problem is to get the information about the FIN which is sent by the remote side. I do not find any functions in the lwIP API to detect this. So the only way is a timer for each connection, closing it i.e. 60 seconds after the last received packet.

Or is there a way to detect the remote FIN and close the connection by myself?

Thank you,
Marco


reply via email to

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