简体   繁体   中英

Persistent TCP connection between hosts, even if IP address changes

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM