Is there any way to get the port before the socket closes?