public void register(int clientId) throws ClientAlreadyExistsException, ClientRegisterFailureException {
        _clientId = clientId;
        try {
            _out.writeInt(8); //Size
            _out.writeInt(Response.MSG_CLIENT_REGISTER);
            _out.writeInt(_clientId);
            _out.flush();

            int messageType = _in.readInt();
            if(messageType != Response.STATUS_OK) {
                int errorCode = _in.readInt();
                if(errorCode == Response.ERR_CLIENT_CREATE_EXCEPTION) {
                    throw new ClientRegisterFailureException(new Exception());
                } else if (errorCode == Response.ERR_CLIENT_ALREADY_EXISTS_EXCEPTION) {
                    throw new ClientAlreadyExistsException(new Exception());
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        _registered = true;
    }