1

How can I have a persistent TCP connection to another remote host, even when IP address changes?

Say I create a program to connect to an IP address. After a while (PC restart, etc) the IP address changes and my program wont connect to the target PC anymore.

There exists something called DNS where you can type a domain and you will get back a valid IP address. For that I hear you need to host a server and pay for that.

Skype for example is P2P. How does that work?

Is there a way to programmatically make a server that someone (who is NOT in my local lan) can always connect to, even if my IP address changes?

vhu
  • 12,244
  • 11
  • 38
  • 48
user3763903
  • 35
  • 1
  • 6
  • 1
    Skype (and other voice/video systems like that) most likely doesn't use TCP connections, but UDP. – Some programmer dude Apr 19 '15 at 10:20
  • no difference thats also ip ... and it also uses ip adresses – user3763903 Apr 19 '15 at 10:21
  • 1
    Probably Skype servers and other computers running Skype act as domain servers. – Marian Apr 19 '15 at 10:22
  • i also thought about that method, cause i think irc also works like that ... but is that a fact or is there no way around? and if it is so how does the ppl ho offer These dns Servers make them?? do they implement some Routing protocol to do that?? can i also make that :D? – user3763903 Apr 19 '15 at 10:24

1 Answers1

2

You can use p2p naming mechanism to connect to a machine even after its address changes. Microsoft has PNRP name service which uses p2p naming system to generate a unique name to a computer. Using this PNRP name, you can connect to the machine even after its IP address changes. Check the below link on the details: https://technet.microsoft.com/en-us/library/bb962088.aspx

Skype might also be using similar mechanism to identify the other peers address.

dvasanth
  • 1,337
  • 1
  • 9
  • 10