Replace usage of inet_ntoa() with getnameinfo()

It's threadsafe and protocol independant.

Also removed a couple of possible silent-truncation bugs.
(cherry picked from commit 0ec54996a67e06f33f902fce64dec14d07553a2d)
Simplified some braindead logic, added comments.
(cherry picked from commit 01c002e227815be042eb8a41c2aad3625c58ef6f)
Fix regression of setting VIPADDRESS to 127.0.0.1

See redmine #3010, now it's set to the first address of non-loopback
interface.
(cherry picked from commit 31594510c8acc950ebaacbc596926956be7f726f)