No FIN sent?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

No FIN sent?

Jump to solution
3,187 Views
kackle123
Contributor IV

I have a Visual Basic client program that sends data over TCP to a K64 running a simple, custom server under MQX 4.2.  The client sends its data and then informs the server that it's closing the socket connection.  Wireshark shows a FIN is sent by the client and the server's TCP stack automatically responds with its ACK.  After that though, the server never sends its FIN (or even a RST) to the client automatically (nor manually when I call closesocket(), shutdown() or shutdownsocket() in my server code).  The server really sends no data after the initial handshake that I wrote, so it shouldn't be "waiting" for anything. 

If I run a web server in MQX, the web server will correctly send out a FIN first, followed later by the PC web browser's ACK, then a FIN.  But when a remote client initiates closing a connection, this tear-down handshake doesn't happen.  Can someone try and confirm this behavior?

TL; DR:

The connection closer sends FIN; MQX sends ACK back, but no FIN.

Labels (1)
0 Kudos
Reply
1 Solution
2,568 Views
kackle123
Contributor IV

Thank you for the response.  After much investigating, I suspect the reason my MQX server doesn't send a FIN is that I was immediately rebooting the K64 after receiving the updated firmware that the server is designed to accept.  When I call shutdown(), it exits before the FIN gets sent through the Ethernet port.  Adding a delay after the shutdown() call and before the K64 reboot fixed the issue.

View solution in original post

0 Kudos
Reply
2 Replies
2,569 Views
kackle123
Contributor IV

Thank you for the response.  After much investigating, I suspect the reason my MQX server doesn't send a FIN is that I was immediately rebooting the K64 after receiving the updated firmware that the server is designed to accept.  When I call shutdown(), it exits before the FIN gets sent through the Ethernet port.  Adding a delay after the shutdown() call and before the K64 reboot fixed the issue.

0 Kudos
Reply
2,962 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Kackle:

Please be noted that if the socket is to be shut down gracefully,  RTCS tries to deliver all the data that is in its send buffer for the socket. By default, RTCS maintains the socket connection for two seconds after the remote endpoint disconnects.

For a connected stream, the behavior of closesocket depends on the SO_LINGER socket option:

pastedImage_1.png

Regards

Daniel

0 Kudos
Reply