In message <CAP-guGVA4eHv0K=U=x2B-WPYDy2RQ7ZE1Di2AHc+dmA_huyGzA@mail.gmail.com>, William Herrin writes:
On Mon, Feb 27, 2012 at 3:43 PM, david raistrick <drais@icantclick.org> wro= te:
On Mon, 27 Feb 2012, William Herrin wrote:
In some cases this is because of carelessness: The application does a gethostbyname once when it starts, grabs the first IP address in the list and retains it indefinitely. The gethostbyname function doesn't even pass the TTL to the application. Ntpd is/used to be one of the notable offenders, continuing to poll the dead address for years after the server moved.
While yes it often is carelessness - it's been reported by hardcore development sorts that I trust that there is no standardized API to obtai= n the TTL... =A0What needs to get fixed is get[hostbyname,addrinfo,etc] so programmers have better tools.
Meh. What should be fixed is that connect() should receive a name instead of an IP address. Having an application deal directly with the IP address should be the exception rather than the rule. Then, deal with the TTL issues once in the standard libraries instead of repeatedly in every single application.
No. connect() should stay the way it is. Most developers cut and paste the connection code. It's just that the code they cut and paste is very old and is often IPv4 only.
In theory, that'd even make the app code protocol agnostic so that it doesn't have to be rewritten yet again for IPv12.
getaddrinfo() man page has IP version agnostic code examples. It is however simplistic code which doesn't behave well when a address is unreachable. For examples of how to behave better for TCP see: https://www.isc.org/community/blog/201101/how-to-connect-to-a-multi-homed-se... Mark -- Mark Andrews, ISC 1 Seymour St., Dundas Valley, NSW 2117, Australia PHONE: +61 2 9871 4742 INTERNET: marka@isc.org