public void run() {
		while (!stop.get()) {
			RPCEnvelope req = requestQueue.poll();
			if (req != null) {
				try {
					encoder.encode(sout, req);
					if(req.getEnvelopeType()==RPCEnvelope.RPC_ENVELOPE_TYPE_ADMIN){
						RPCAdminEnvelope admin = (RPCAdminEnvelope)req;
						if(admin.getAdminCommand()==RPCAdminCommand.SHUTDOWN.getValue()){
							RPCAdminEnvelope preq = (new RPCAdminEnvelope()).setAdminCommand(RPCAdminCommand.PING);
							sendRequest(preq);
						}
					}
					RPCEnvelope env = decoder.decodeNow(sin);
					for (ProtocolDecodeHandler handler : registeredHandlers) {
						handler.onReceive(env);
					}
				} catch (IOException iex) {
					shutdown();
					for (ProtocolDecodeHandler handler : registeredHandlers) {
						handler.onSocketIOError(iex);
					}
					
				} catch (Exception ex) {
					log.warn("Unexpected err", ex);
				}
			} else {				
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					;
				}				
			}
		}
	}