fixed getport() so sockets are not left open after errors.