I am writing a TCP client using lwIP raw API, on Linux. This client talks over a socket connection, to a TCP echo server (running on windows. Developed using winsock). And closes the connection (using tcp_close) as soon as it receives data from server.
tcp_close() sends a FIN and ACK to the server. And lwIP waits to get FIN from the server. But the server never sends that.
I tested using Linux socket API (for client) and made the same observation. Even after receiving ACK and FIN from the client, the server tries to resend earlier data repeatedly. And also server never sends FIN from it's side.
Why is this the case when, TCP documentation says that the client is expected receive FIN from the server? Is the client always expected to send RST to close connection from it's side? And FIN is used only for closing connection initiated by the server?