TCP Refusing FIN

Thank you both for the great help so far. I’ll try to summarize what I’ve found so far.

This workaround seems to have worked! Here is the capture from a test with the workaround and also the debug messages. In the capture there are normal disconnects at 13s and 27s. The REFUSE FIN happens at 50s.
refuse_fin_workaround.zip (479.8 KB)

Gain: Socket 6000 now has 1 / 1 child
prvSocketSetMSS: 1460 bytes for C0A81505ip:50565
Socket 6000 -> C0A81505ip:50565 State eCLOSED->eSYN_FIRST
prvWinScaleFactor: uxRxWinSize 2 MSS 1460 Factor 0
Socket 6000 -> C0A81505ip:50565 State eSYN_FIRST->eSYN_RECEIVED
TCP: passive 6000 => C0A81505ip:50565 set ESTAB (scaling 1)
Socket 6000 -> C0A81505ip:50565 State eSYN_RECEIVED->eESTABLISHED
Starting network tasks
TCP: RST received from C0A81505ip:50565 for 6000
Socket 6000 -> C0A81505ip:50565 State eESTABLISHED->eCLOSED
error reading from socket
Lost: Socket 6000 now has 0 / 1 children
FreeRTOS_closesocket[6000 to C0A81505ip:50565]: buffers 64 socks 1
Rx task is deleting itself
Notify txTask to shutdown
Tx task is deleting itself
Gain: Socket 6000 now has 1 / 1 child
prvSocketSetMSS: 1460 bytes for C0A81505ip:50569
Socket 6000 -> C0A81505ip:50569 State eCLOSED->eSYN_FIRST
prvWinScaleFactor: uxRxWinSize 2 MSS 1460 Factor 0
Socket 6000 -> C0A81505ip:50569 State eSYN_FIRST->eSYN_RECEIVED
TCP: passive 6000 => C0A81505ip:50569 set ESTAB (scaling 1)
Socket 6000 -> C0A81505ip:50569 State eSYN_RECEIVED->eESTABLISHED
Starting network tasks
TCP: RST received from C0A81505ip:50569 for 6000
Socket 6000 -> C0A81505ip:50569 State eESTABLISHED->eCLOSED
error reading from socket
Lost: Socket 6000 now has 0 / 1 children
FreeRTOS_closesocket[6000 to C0A81505ip:50569]: buffers 64 socks 1
Rx task is deleting itself
Notify txTask to shutdown
error writing to socket
Tx task is deleting itself
Gain: Socket 6000 now has 1 / 1 child
prvSocketSetMSS: 1460 bytes for C0A81505ip:50576
Socket 6000 -> C0A81505ip:50576 State eCLOSED->eSYN_FIRST
prvWinScaleFactor: uxRxWinSize 2 MSS 1460 Factor 0
Socket 6000 -> C0A81505ip:50576 State eSYN_FIRST->eSYN_RECEIVED
TCP: passive 6000 => C0A81505ip:50576 set ESTAB (scaling 1)
Socket 6000 -> C0A81505ip:50576 State eSYN_RECEIVED->eESTABLISHED
Starting network tasks
Refusing FIN[6000,50576]: RxCompl 1 tx done 0
TCP: RST received from C0A81505ip:50576 for 6000
Socket 6000 -> C0A81505ip:50576 State eESTABLISHED->eCLOSED
error reading from socket
Lost: Socket 6000 now has 0 / 1 children
FreeRTOS_closesocket[6000 to C0A81505ip:50576]: buffers 64 socks 1
Rx task is deleting itself
Notify txTask to shutdown
error writing to socket
Tx task is deleting itself

The PC App is using winsock. Its also very old and frankly badly programmed. Your intuition seems to be right though. There is no call at all to the shutdown function the PC app only calls closesocket. This is maybe why the FIN packets are missing even on the “successful” disconnects. I can try to make your suggestions to make it better behaved, but have not yet while testing the workaround.