No FIN sent?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
2,558件の閲覧回数
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.

ラベル(1)
0 件の賞賛
1 解決策
1,939件の閲覧回数
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 件の賞賛
2 返答(返信)
1,940件の閲覧回数
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 件の賞賛
2,333件の閲覧回数
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 件の賞賛