Why the square brackets? I think this looks wrong for IPv6 (in that inet_ntop doesn't enclose the IPv6 address in square brackets, so there's nothing distinguishing the address from the port.