public void deregister() throws ClientDeregisterFailureException, ClientDoesNotExistException {
        try {
            _out.writeInt(8); //Size
            _out.writeInt(Response.MSG_CLIENT_DEREGISTER);
            _out.writeInt(_clientId);
            _out.flush();

            int messageType = _in.readInt();
            if (messageType != Response.STATUS_OK) {
                int errorCode = _in.readInt();
                if (errorCode == Response.ERR_CLIENT_DELETE_EXCEPTION) {
                    throw new ClientDeregisterFailureException(new Exception());
                } else if (errorCode == Response.ERR_CLIENT_DOES_NOT_EXIST_EXCEPTION) {
                    throw new ClientDoesNotExistException(new Exception());
                }
            }
            tearDown();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        _registered = false;
    }