Reconnecting to Ethernet

OK. Try this. It adds a 10 second timeout. If no characters are received for 10 seconds, it closes its end of the connection.

  int noCharCount = 0;
  
  while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      Serial.write(inChar);
      noCharCount = 0;
    }

    delay(10);
    noCharCount++;

    // change this value to suit you. this is 10 seconds    
    if(noCharCount > 1000)
    {
      Serial.println();
      Serial.println("Timeout");
      client.stop();
    }
    
  }