@SuppressWarnings("unchecked")
  @Override
  public void run()
  {
    try
    {
      while (true)
      {
        ObjectInputStream objIn = new ObjectInputStream(socket.getInputStream());
        Object receivedMessage = objIn.readObject();
        if (receivedMessage instanceof Map<?, ?>)
        {
          Map<String, String> map = (Map<String, String>) receivedMessage;
          if (map.containsKey(AgentConfigConstants.NUM_PROGRESS_ID))
          {
            listener.setProgress(map);
          }
          else if (map.containsKey(AgentConfigConstants.STID))
          {
            listener.setStatus(map);
          }
          else
          {
            listener.setConfig(map);
          }
        }
        else
        {
          String strMessage = (String) receivedMessage;
          if (!"OK".equals(strMessage))
          {
            incomingMessages.put(strMessage);
          }
        }
      }
    }
    catch (Exception ex)
    {
      if (ex==null || ex.getMessage()==null) {
    	  listener.disconnect();
    	  LOG.error(DefaultFactory.getFactory().getMessages().getInTraceAgentDisconnected());
      } else if (!ex.getMessage().contains("ocket closed") &&
          !ex.getMessage().contains("onnection reset"))
      {
        ex.printStackTrace();
      }
      listener.disconnect();
    }
  }