[En-Nut-Discussion] TCP state machine reset

Ole Reinhardt ole.reinhardt at embedded-it.de
Wed Nov 5 16:49:30 CET 2014

Hi Alister,

sorry for the late answer. I'm very busy :)

Your code looks ok for the first moment. But there are some questions left:

- What exactly does get_Sony_cmd(&TCPconnected);
  Can you break down the code to a minimum? This seem to be the
  routine, where you read from the socket, right? I just want to get
  sure, that nothing else is the reason for the failing timeout.

- Which behaviour do you expect exactly? When the socket is
  disconnected, the TCP connection is closed (for sure). So in this
  case nothing could be send out from Nut/OS side.

  So your socket would need to stay opened, as long as you want to send
  some data between your two endpoints.

So the next steps would be to review how get_Sony_cmd() is implemented..

Best regards,


Am 04.11.2014 16:41, schrieb alister:
> Hi Ole,
> A few words of explanation may help.
> The Ethernut is a TCP server, and listens for one client only.
> I have a 2 second receive timeout so my program loops waiting for the client.
> When the client connects, I stay connected forever, until the link is broken or power
> fails. Every 15 seconds I send a heartbeat message unless the client sends a
> message requesting data.
> Some of my data is about 12k long, so I make the mss large and the TCP stack
> chops the messages up
> as separate packets of 1514 bytes according to Wireshark. That all works nicely!
> My only problem is that if the client disconnects, I close the socket and open it
> again,
> but the 2 second timeout no longer works. I can receive client requests when he
> reconnects,
> but without the receive timeout, my heartbeats fail to go out. 
> Greetings,
> Alister
> On Tue 04/11/14  3:05 PM , Ole Reinhardt ole.reinhardt at embedded-it.de sent:
>> Hi Alister,
>> could you please post a short code example of how you setup your
>> sockets?
>> Best regards,
>> Ole
>> Am 04.11.2014 15:56, schrieb alister:
>>> Hi All,
>>> If the far end closes my TCP server link on an
>> Ethernut 1.3 then the next time I> make a TCP socket the receive timeout function
>> doesn't seem to work.>
>>> Is there a way to reset the TCP state machine or
>> have I done something nooby?>
>>> I wait 2 seconds before opening a new
>> socket.>
>>> Regards,
>>> Alister
>> _______________________________________________>
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion>
>> --
>> kernel concepts GmbH            Tel: +49-271-771091-14
>> Sieghuetter Hauptweg 48         Mob: +49-177-7420433
>> D-57072 Siegen
>> http://www.embedded-it.dehttp://www.kernelconcepts.de

kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen

More information about the En-Nut-Discussion mailing list