4

In Windows (and probably in other operating systems), if a process has a TCP connection with another process on another machine, and then I terminate the process, an RST packet will be sent to the other machine to indicate the end of the connection.

Now imagine that when the process is terminated, there were still some data left in the send buffer. What will happen in this case, will these remaining data be sent to the other machine followed by an RST packet, or will these remaining data be ignored and only an RST packet is sent?

1

1 Answer 1

1

The RST is sent immediately and the data is discarded.

7
  • Is this true? I know there are some cases where Windows will continue transmitting the send buffer after the application has terminated. I thought RST was only sent is SO_LINGER is set to 0, otherwise it tries to gracefully shut down.
    – dauphic
    Commented Mar 2, 2015 at 20:32
  • @CollinDauphinee RST is sent under a variety of circumstances: the one you mention is the least likely of all of them. The question isn't whether RST is sent, it is what happens to the data if RST is sent. Some platforms send a FIN after the data instead.
    – user207421
    Commented Mar 2, 2015 at 20:54
  • I think the poster is under the impression that an RST is always sent when the process terminates. Likely they don't know about TIME_WAIT.
    – dauphic
    Commented Mar 2, 2015 at 20:56
  • @CollinDauphinee RST is sent, on some platforms, if the socket hasn't been closed by the application. Other platforms send a FIN, which can lead to TIME_WAIT.
    – user207421
    Commented Mar 2, 2015 at 20:58
  • @CollinDauphinee OTOH If the application has closed the socket with pending send data, all platforms will transmit it all, followed by a FIN, even after the application has terminated. This isn't TIME_WAIT either, though: the connection is still ESTABLISHED during this period. TIME_WAIT only starts after the FIN has been ACKed.
    – user207421
    Commented Mar 2, 2015 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .