logger.debug("Waiting for 'ready' from the client");
Message msg = receiveMessage(null);
if(!(msg instanceof MessageReady))
throw new ProtocolException("The 'ready' message was expected", this);
MessageReady msgReady = (MessageReady)msg;
this.clientName = msgReady.getClientName();
logger.debug("Client connected: " + this.clientName);
if(this.clientType != msgReady.getClientType())
throw new ClientException("Expected client type " + this.clientType
+ " does not match the real client type " + msgReady.getClientType(), this);
}