[Top][All Lists]

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

Re: [lwip-users] lwip_close

From: Atte Kojo
Subject: Re: [lwip-users] lwip_close
Date: Thu, 25 Aug 2005 09:41:40 +0300
User-agent: KMail/1.8.2

On Wednesday 24 August 2005 16:41, Ashutosh Srivastava wrote:
> My question is, for a lwip_close call, why netconn_delete () function does
> not wait for the ACK from server for the FIN segment sent?

I think I've seen this question before in this list. First I'd like to ask 
that why would you want to wait for the ACK after you have closed the 

Also, a TCP connection isn't closed after the ACK for the first FIN segment 
arrives. The connection is closed when both ends have sent a FIN and received 
an ACK for it. i.e.

local                   remote
FIN --------------->
        <-------------- ACK
        <-------------- FIN
ACK ------------->


local                   remote
FIN --------------->
        <--------------- ACK,FIN
ACK ------------->

> Ideally, I thought the lwip_close () implementation should be like the
> lwip_connect () function call where a callback function is called when a
> SYN ACK is received from the server.

The lwip_close call just tells the stack that the application no longer needs 
the socket. From the application's point of view the connection exists no 
more. The stack takes care of all the necessary housekeeping in closing the 
TCP connection from this point forward (i.e. sending and receiving the 
necessary FINs and ACKs and freeing the resources that were reserved for the 

You should remember that conceptually the socket layer has nothing to do with 
TCP or UDP or any other protocol. It is just a very simple API with which one 
can do almost any kind of I/O.

I hope this helps.
        - Atte

reply via email to

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