Added printing of port number.
Added code to close connections.