Fix bug. Retrive local address and port properly for both tcp and tls