refactored to be ip_address friendly for tcp