public void run() {
        MethodResponse response;

        try {
            MethodRequest request = readFromSocket(this.socket);
            Object callee = this.nameService.retrieve(request.getTarget());

            Method method = callee.getClass().getMethod(request.getMethod(), request.getTypes());
            method.setAccessible(true);
            Object result = method.invoke(callee, request.getArguments());

            response = new MethodResponse(result, null);
        } catch (InvocationTargetException e) {
            response = new MethodResponse(null, e.getTargetException());
        } catch (Exception e) {
            response = new MethodResponse(null, e);
        }

        writeToSocket(socket, response);

        try {
            this.socket.close();
        } catch (IOException e) {
            System.err.println("Error closing socket.");
            e.printStackTrace();
        }
    }