4 ms·
And please make it 127.0.0.1 and not ::1. I've found several instances where localhost resolved to ::1.
by rgacote 10y ago
And please make it 127.0.0.1 and not ::1.
I've found several instances where localhost resolved to ::1.
- ciupicri 10y agoUse localhost4 & localhost6 if you don't want that kind of surprises.
- deathanatos 10y agoIt resolves to both on most major OSs, and I think it should as long as something isn't horribly misconfigured. Most networking code on Unix-like OSes should (eventually) boil down to something like a call to getaddrinfo(2), a system call that returns the set of addresses that match a query — typically a hostname. The result set for localhost will often include both ::1 and 127.0.0.1, but the result from the function also includes what type of address (IPv4 or IPv6, essentially) they are: you're supposed to take both the address (such as ::1) and the address family (such as IPv6) and pass them to socket(2). (and if that fails, try the next one in the list) This mechanism lets you resolve domains that might be IPv4 or IPv6 only, and not even need to care in the code: if the domain is IPv4 only, then getaddrinfo only returns addrinfos w/ IPv4 addresses. Likewise for v6. You forward the information to socket(2) and connect(2), and don't ever need to deal with a concrete addrinfo object.