public Object lookupObject(String name) throws ObjectNotFoundException
    {
        try {
            Socket sock = new Socket(servername, port);
            OutputStream out = sock.getOutputStream();
            out.write(lookupCommand);
            out.write(endofline);
            out.write(endofline);

            ObjectOutputStream dout = new ObjectOutputStream(out);
            dout.writeUTF(name);
            dout.flush();

            InputStream in = new BufferedInputStream(sock.getInputStream());
            skipHeader(in);
            ObjectInputStream din = new ObjectInputStream(in);
            int n = din.readInt();
            String classname = din.readUTF();
            din.close();
            dout.close();
            sock.close();

            if (n >= 0)
                return createProxy(n, classname);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw new ObjectNotFoundException(name, e);
        }

        throw new ObjectNotFoundException(name);
    }