public void dispatch(Command command) throws IOException {
        Socket socket = null;
        BufferedReader in = null;
        PrintWriter out = null;
        try {
            socket = new Socket(client.getHost(), client.getPort());
            in = new BufferedReader(new InputStreamReader(socket.getInputStream()), Character.SIZE);
            out = new PrintWriter(socket.getOutputStream(), true);

            out.println("passwd " + client.getPassword());
            validAuth(in);
            out.println(command.getCommand());
            handleCmdAnswer(in, command);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e1) {
                }
                in = null;
            }
            if (out != null) {
                try {
                    out.close();
                } catch (Exception e1) {
                }
                out = null;
            }
            if (socket != null) {
                try {
                    socket.close();
                } catch (Exception e) {
                }
                socket = null;
            }
        }
    }