+ 3
How to connect a client to a server over internet?
I am trying to create a server - client based chat app. I am able to connect the client to server over the web with IPv4 address. But as soon as I close my server and then restart it later on, the server IP gets changed. So I am unable to figure out a way to connect client to that server. How other Instant messaging app like Whatsapp, do that? Server code: https://code.sololearn.com/cxUVjJ8aMPAa/?ref=app GUI Client code: https://code.sololearn.com/cv59nGyu9xL0/?ref=app
2 odpowiedzi
+ 5
The Domain Name System (DNS). Records in DNS map names to IP addresses (+ other things), so that clients only need to know host names. It is then the responsibility of the host or domain admin to update DNS when the host's IP address changes.
Companies like Whatsapp often just run their own DNS name servers. In contrast, individuals usually add their hostname(s) to someone else's DNS server (which then becomes "authoritative" for a domain's host names) after signing up for / buying a domain or hosting service; free options include "dynamic DNS".
In case you want to run your own DNS service (publicly; private-only DNS is simpler because you control everything), just note that you still need to find a public server that will list your DNS server (as a name->IP address mapping) so that the Internet recognizes your server as the authority for your host names.