Andrew Chernow <ac(at)esilo(dot)com> writes:
> Tom Lane wrote:
>> The portability risk is in the "manually set the port" part.
> Right. If this method is limited to _AIX and only when the failure case
> occurs, there are no portability issues.
That seems like unnecessary complexity (which carries its own risks).
I thought this sketch was about right:
#ifdef _AIX
getaddrinfo(hostname, NULL /* servname */, ....);
// manually set the port
#else
getaddrinfo(hostname, servname, ....); /* same code as now */
#endif
although please flip it around to ifndef. The simpler and more general
case should usually be first to aid the reader.
regards, tom lane