I don't know of any IP addresses that it's safe to hardcode in software like this.
However, there are hostnames that it's safe to hardcode: the DNS root servers, a.root-servers.net etc.
If you have working hostname resolution, even if intermittently, you could in principle resolve those, and then check connectivity. However, it's probably not a good idea to use these crucial public resources for something so pointless!
Interestingly, all of the root servers except G also have a companion website, ${letter}.root-servers.org, which could perhaps be used for an HTTP connectivity check. Those websites aren't hosted on the same machines as the nameservers.