Score:1

Socket In TIME_WAIT on Client when exit, but not on restart

pe flag

Linux Server (port 7000)

Windows Client (port 8585)

Scenario 1: Client Restart

  • Restart on client

  • Server socket read returns -1, gets errno 104, Connection reset by peer

  • Server closes its socket connection to the client

  • Client calls close on its socket

  • Client restarts and is able to connect right away to Server

Scenario 2: Client Exit

  • Exit on client

  • Server socket read returns 0, gets errno 11, Resource temporarily unavailable

  • Server closes its socket connection to the client

  • Client calls close on its socket

  • Client netstat shows

    TCP Client IP:8585 Server:7000 TIME_WAIT InHost

What is causing the server socket read to return 0 on restart, and not -1 with errno 104?

The client is calling the shutdown/close on the windows socket for both restart/exit. I understand what the TIME_WAIT state is for TCP. But I don't understand what is causing this TIME_WAIT.

Wireshark Restart: There is a TCP [RST, ACK] from the Server

Wireshark Exit: There is a TCP [FIN, ACK] from the Server

Not sure why they would differ if I am calling the same close method for the client socket.

cn flag
Already answered here: https://superuser.com/questions/173535/what-are-close-wait-and-time-wait-states and here: https://learn.microsoft.com/en-us/answers/questions/230227/time-wait-from-netstat
RAZ_Muh_Taz avatar
pe flag
Why can i reconnect to the server right away on a restart. But when i exit and then reopen the client, it takes 2 minutes to connect? Doesn't make sense. I should have the same behavior for both and I don't.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.