@Override
    public void run()
    {
        msg.printMessage("Waiting for incoming connection request...");
        String fromClient;
        TCPHandShakeProtocol protocol = new TCPHandShakeProtocol();
        
        try
        {
            clientSocket = serverSocket.accept();
            msg.printMessage("Connected to " + clientSocket.getRemoteSocketAddress().toString());
            os = new DataOutputStream(clientSocket.getOutputStream());
            in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

            //===========================SERVER LOGIC BEGINS HERE================================
            while(isRunning)
            {
                fromClient = in.readLine();
                if(fromClient != null)
                {
                    if(fromClient.equals("End"))
                    {
                        this.isRunning = false;
                    }
                    else
                    {
                        msg.printMessage("Command received from Client: " + fromClient);
                        os.write(protocol.processIncomingRequest(fromClient));
                        msg.printMessage("Response sent to Client.");
                    }
                }
            }
            //============================SERVER LOGIC ENDS HERE=================================
        
            msg.printMessage("Trying to close connections...");
        
            in.close();
            os.close();
            clientSocket.close();
            serverSocket.close();
        }
        catch(IOException ioex)
        {
            String cause = ioex.getMessage();
            msg.printMessage(cause);
                
            if (cause.equals("Accept timed out"))
            {
                try
                {
                    serverSocket.close();
                } catch (IOException ex)
                {
                        msg.printMessage(ex.getMessage());
                }
            }
        }
        catch(Exception e)
        {
            msg.printMessage("Exception: " + e.getMessage());
        }
        finally
        {
            msg.printMessage("Server Stopped.");
        }
    }