Added code to connect to server. It checks if the port number is valid before you can connect.