network programming problem
every once a while one of my programs which connects to a server using TCP shows some very odd behaviour, which shows up like this:
1. after a application timeout (i.e. i don't get an application protocol response for a message send) i close the socket using
2. i re-connect to the server and send() a message, which works fine
3. immediately after this, i'm falling into recv() to wait for an answer, recv returns 0 which indicates me the destination has closed the connection
4. i continue with step 2 (after a short delay), unfortunately this leds to a loop
Up to now i always thought the remote side has some serious problems causing this behaviour, but here is what puzzles me:
I did a tcpdump to check whats really going on, and it shows me that MY host is sending a tcp packet with the data and the FIN, PSH, ACK flags set to the remote host?!?!
Does this sound familiar to anyone? It is not what my program is doing or given back by the socket functions. What could cause such a tcp behaviour? When i did a netstat on the remote IP, i saw a lot of connections in the LAST_ACK state.
Any help or hints (is there a better place to ask this?) would be greatly appreciated.