C#.net TCPClient to Photon

Hi i have small project where i want to Write to the photon from a Console app

But the Photon does not recive anyting but it is connected

My code is as follows

Console APP:

            TcpClient client = new TcpClient("192.168.1.230", 23);
            StreamWriter sw = new StreamWriter(client.GetStream());
            StreamReader sr = new StreamReader(client.GetStream());
            sw.WriteLine("ON");
            sw.Close();
            client.Close();
            Console.ReadLine();

Particle Code:

      TCPServer server = TCPServer(23);
      TCPClient client;
      int blue = A3;
      String incomming;

      void setup() {
      pinMode(blue, OUTPUT);
      server.begin();
      Serial.begin(9600);
      }

    void loop() {
    if (client.connected())
    {
        //Serial.println("Connected");
        
        if(client.available())
        {
            incomming = client.readStringUntil('\n');
            incomming.trim().toUpperCase(); 
            if (incomming == "ON")
            {
                digitalWrite(blue, HIGH);
                server.println("OK IS ON");
            }
            if (incomming == "OFF")
            {
                digitalWrite(blue, LOW);
                server.println("OK IS OFF");
            }
            // if (incomming != "ON" && "OFF")
            //{
            //    Serial.println("Wrong Command Try again");
            //    Serial.println(incomming);
            //    
            //client.flush();
            //    incomming = "";
            //}
        }
       }
       else 
       {
           client = server.available();
       }
   }

Hope someone can help

Try to flush the streams and wait a bit in the console APP:

            TcpClient client = new TcpClient("192.168.1.230", 23);
            StreamWriter sw = new StreamWriter(client.GetStream());
            StreamReader sr = new StreamReader(client.GetStream());
            sw.WriteLine("ON");
            sw.Flush();
            Thread.Sleep(2000);
            sw.Close();
            client.Close();
            Console.ReadLine();

Thanks it Worked