We're missing my most recent fix in this area - we need to use PJSIP_TRANSPORT_TCP6 if it's an IPv6 address.  This reinforces my comment above about deduplicating code.