[Top][All Lists]

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

Re: [lwip-users] TCP FIN question

From: Yadnesh Phadke
Subject: Re: [lwip-users] TCP FIN question
Date: Thu, 14 Sep 2006 16:52:34 +0530

Thank you. All clarified.

Yadnesh Phadke 

On 9/14/06, Kieran Mansley <address@hidden> wrote:
On Thu, 2006-09-14 at 16:08 +0530, Yadnesh Phadke wrote:
> I have a simple server, that waits in recv().  When it gets any data
> from the client, it sends back the same data, and again waits on recv
> ().
> Now, the server has not got anything to send, till client sends
> data.
> Client sends FIN and ACK for data received from server.  I expected
> the server to respond with a FIN in this case.

So have the server close the connection too when it gets an error or
zero bytes from recv() to indicate that the client has closed the
connection.  It will then complete the close handshake by sending a FIN.
This won't happen by magic for you because the network stack doesn't
know that you're using just a simple echo server.

> Another related question, How would the client come to know that
> server has sent all the data that it wanted to send?  Is there any
> specific flag used?

It's not possible for the network stack to infer that the application
does not have any more data to send (unless the application closes the
connection I suppose), so you can't get this information from one of
your applications to another unless you get one of them to tell the
other.  You need to write a protocol for your client and server that,
for example, specifies that the server will send the length of the data
it is going to send, then the data.  The client can then read the length
of the data to expect, followed by the data, and know when it has
received it all.

This isn't really lwIP specific stuff, and so this mailing list isn't
the best place to discuss such things.  I suggest you read a good book
or tutorial on network communications using TCP/IP.


lwip-users mailing list

reply via email to

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