public void run()
    {
        while(running)
        {
            if(connected)
            {
                if(debugMode) TEMPReadFromSocket();
                else ReadFromSocket();
            }
            /*else
            {
                //if not connected, wait a bit before rechecking
                try {
                    Thread.sleep(500);
                } catch (InterruptedException ex) {
                    //error related to sleeping?
                }
            }*/
            listener.update(currentMessage);
            try {
                if(!currentMessage.equals(oldMessage) && !currentMessage.equals(""))
                {
                    DatabaseDataObjectUtilities.addMessageToBlackBox(listener.getCurrentUnixTime(), currentMessage);
                    oldMessage = currentMessage;
                }
            } catch (SQLException | ClassNotFoundException ex) {
            }            
        }
    }