0

I have tcp connection to some tcp server on internet. Tcp client is a simple application that I have created which works on my computer. The problem is that when I change my ip address through the windows network and sharing center, my tcp connection shuts down instantly without using any timeout. Do you have any idea why it happened?

I have a feeling that windows is sending a closing signal to my tcp connections when ı change my ip adress through the windows network and sharing center. But I can't prove it! I couldn't find anything in my research on the internet neither.

Edit: The tcp server is waiting for a while (timeOut) if my connection is physically closed(unplug cable). But if I change my ip address as I mentioned, the connection is closed instantly.

2 Answers 2

0

TCP is a connection oriented protocol that uses stream sockets. It is bound by IP-address and port-number at both endpoints.

See RFC 793 (Transmission Control Protocol), specifically section 2.7:

2.7. Connection Establishment and Clearing

To identify the separate data streams that a TCP may handle, the TCP provides a port identifier. Since port identifiers are selected independently by each TCP they might not be unique. To provide for unique addresses within each TCP, we concatenate an internet address identifying the TCP with a port identifier to create a socket which will be unique throughout all networks connected together.

In connection oriented protocol, a logical channel is established between the peers before exchanging data. So, if the IP address is changing, it has to tear down the existing connection and re-establish a new connection, which obviously is disruptive.

IP address change will be disruptive as higher level protocols like TCP will be shutdown. Mobile phones overcome such scenarios by using specialized protocols such as GTP or Mobile IP.

In short, part of the procedure of changing the IP address of the sender involves the closing of all connections employing the old address.

Closing is different from cutting the communication path, because the other side is notified that the socket has been closed in an orderly manner and will immediately close its own socket on its own side.

This is unlike when the communication path is brutally cut off, as in such cases the other side will wait a predetermined amount of time before deciding to close the connection unilaterally, and even this requires that keep-alive is activated on the connection or long waits can happen.

1
  • You destroyed all of my questions in this particular matter with one good blow. Thank you. Commented Mar 30, 2020 at 15:02
0

If you change your IP address, the connection can no longer see you.
It may be polling you for minutes to see if you're still there, but you're not.

To you, the connection appears to be instantly closed. It doesn't actually matter at this point whether it tried to do this tidily… to the remote machine, you simply vanished & it has no way of knowing where you went.

1
  • Thank you for answer. But I have physical access to the server. I can see when the connection is lost for the server. When I unplug the client, the server is waiting for a while(some kind a timeout) before closing the connection. But if I change the ip address of client as I mentioned, the server closes the connection directly . Commented Mar 30, 2020 at 8:30

You must log in to answer this question.

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