need help about client

i used android app as my client that controls my arduino(server).. the communication between the too is good at the "first" connection.. now when i exit my app, and i enter again to the server.. i cannot control it anymore.. my app can still accept data from the arduino but my arduino does not accept any commands from my app.. i just need to know how to really stop a client that my arduino will again w8 for a new client.. i guess client.stop() does not really close the connection of my previous client.. anyway hers my code hope you can help me

#include <SPI.h>
#include <Ethernet.h>

int Led1 = 7;
int But1 = 8;
int Led2 = 6;
int But2 = 5;
boolean x = 0;
boolean y = 0;


byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x55, 0x64 };  //<----ILISI NI
IPAddress serverIP(192,168,1,38); //<----ILISI NI
int serverPort=8080;

EthernetServer server(serverPort);

void setup()
{
  
  pinMode( Led1, OUTPUT);
  pinMode( Led2, OUTPUT);
  pinMode( But1, INPUT);
  pinMode( But2, INPUT);
  Serial.begin(9600);
  Ethernet.begin(mac, serverIP);
  server.begin();
  Serial.println("Server started");

}

void loop()
{
  
  
  if(x == false){
        if(digitalRead(But1) == HIGH){
            x = true;
             if (digitalRead(Led1) == HIGH){
                 digitalWrite(Led1, LOW);
                 server.println("A0&");
                 }
             else {
                 digitalWrite(Led1,HIGH);
                 server.println("A1&");
                  }
              }
          }
    if(digitalRead(But1)== LOW){
        x = false;
    }
    
     if(y == false){
        if(digitalRead(But2) == HIGH){
            y = true;
             if (digitalRead(Led2) == HIGH){
                 digitalWrite(Led2, LOW);
                 server.println("B0&");
                 }
             else {
                 digitalWrite(Led2,HIGH);
                 server.println("B1&");
                  }
              }
          }
    if(digitalRead(But2)== LOW){
        y = false;
    }
  
  //recall();
  EthernetClient client = server.available();

  if (client) {
    String commandStr ="";

      while (client.connected()) {
      if(x == false){
        if(digitalRead(But1) == HIGH){
            x = true;
             if (digitalRead(Led1) == HIGH){
                 digitalWrite(Led1, LOW);
                 server.println("A0&");
                 }
             else {
                 digitalWrite(Led1,HIGH);
                 server.println("A1&");
                  }
              }
          }
    if(digitalRead(But1)== LOW){
        x = false;
    }
    
     if(y == false){
        if(digitalRead(But2) == HIGH){
            y = true;
             if (digitalRead(Led2) == HIGH){
                 digitalWrite(Led2, LOW);
                 server.println("B0&");
                 }
             else {
                 digitalWrite(Led2,HIGH);
                 server.println("B1&");
                  }
              }
          }
    if(digitalRead(But2)== LOW){
        y = false;
    }
      if (client.available()) {
        char c = client.read();
        commandStr+=c;
       
       if (c == '&') {
          Serial.println("Android: "+commandStr);
          
          if(commandStr.equals("RESET&")){
            client.flush();
           client.stop();
           client = client.available();
            
          }
	  if(commandStr.equals("REQSTAT&")) {
              String stats = "";
              if(digitalRead(Led1) == HIGH){
                stats += "A1&";
                
               }
              if(digitalRead(Led1) == LOW){
                stats += "A0&";
               }
              if(digitalRead(Led2) == HIGH){
                stats += "B1&";
               }
              if(digitalRead(Led1) == LOW){
                stats += "B0&";
               }
               
               server.println(stats);
	    //COMMANDS HERE
	    //SENDING SAMPLE
	    Serial.print(commandStr);
	  } else if (commandStr.equals("A0&")) {
            digitalWrite(Led1, LOW);
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("A1&")) {
            digitalWrite(Led1, HIGH);
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("B0&")) {
            digitalWrite(Led2, LOW);
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("B1&")) {
            digitalWrite(Led2, HIGH);
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("C0&")){
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("C1&")){
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("D0&")){
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("D1&")){
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("E0&")){
	    Serial.print(commandStr);//COMMANDS HERE
	  } else if (commandStr.equals("E1&")){
	    Serial.print(commandStr);//COMMANDS HERE
	  }
          commandStr="";
        }
      }
     
    }
   
    client.stop();
  }
 
}

I don't see anything wrong in the way you're handling ethernet clients, but I notice that you're using the String class. I can't say for certain that this is causing any problems but it does suffer from a memory corruption problem which can cause problems like this, so I suggest you stop using String anyway. That will either fix the problem, or let us rule String out as a possible cause.

yahh.. if seems to be the problem.. but i use string to confirm messages from my app and vice verso to enable communication..do you have any other solution to resolve this problem?? thank you for the reply

Yes, use c-strings (null terminated char arrays) instead of the String class.