lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwip_close


From: Ashutosh Srivastava
Subject: Re: [lwip-users] lwip_close
Date: Fri, 26 Aug 2005 11:02:30 +0530

Hi Atte,

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

Thanks a lot for the reply. Yes, you are correct, I myself had posted
this question before but no one answered to that :)

Okay, I have understood the fact that TCPIP stack internally handles the
FIN ACK and FIN from the server.

Now, let me describe the problem I am facing because of this. The server
I am connecting to is a shoutcast Internet radio server which streams MP3
data over HTTP. When I close the connection, lwip sends a FIN segment
and comes out. I am not sure why, but the server sends the FIN ACK after
a long time and keeps on sending some more MP3 packets. So, in between
if want to connect to the same server again, it fails because the server is still
sending over the MP3 data for the previous connection and does not get the
SYN ack. Another observation is that, the server itself does not send the FIN
segment, but the lwip timesout itself and deallocates the connection.

That's why I thought that connection should be closed only when the ACK is
received and a FIN is sent from the server.

Is there an alternative method to handle this?

Thanks,
Ashu

----- Original Message ----- From: "Atte Kojo" <address@hidden>
To: <address@hidden>
Sent: Thursday, August 25, 2005 12:11 PM
Subject: Re: [lwip-users] lwip_close


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

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

or

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
connection).

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


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

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