Arduino server receiving freezes

I’m using an Arduino Leonardo + Ethernet shield W5100.
My C# application is client and Arduino is a server.
Client sends to server a lot of small commands (7 byte each) then can take a pause (for seconds or minutes/hours) and then will send commands again etc. Server doesn’t respond - it only receives.
Problem appears when client takes a pause 10+ minutes and then sends commands. This commands will be processed by server only after big delay (10 seconds or around this). Strange fact is that first command sent after pause will be processed at once and others will wait 10 seconds for some reason (all commands sent one by one at 100-500 ms window). And this is repeatable stable situation.
I checked with wireshark - commands left my PC. So this is not a problem of C# application or my network adapter. But every time wireshark shows TCP retransmission messages/errors right after this first succeed message after pause. May be this is a key.
I added some logging and found that all this 10 seconds client.available() function returns false like there is no data in socket.
My server code looks like that:

#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 13);
EthernetServer server(1234);

void setup()
{
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  EthernetClient client = server.available();
  if (client)
  {
    int commandLength = 7;
    int currentIndex = 0;
    byte command[commandLength];
    while (client.connected())
    {
      while (client.available())
      {
        int inByte = client.read();
        if (inByte == -1)
          continue;
        command[currentIndex] = inByte;
        currentIndex++;
        if (currentIndex == commandLength)
        {
          ProcessCommand(command);
          currentIndex = 0;
        }
      }
    }
  }
}

void ProcessCommand(byte* command)
{
}

What can be a reason for such behaviour?

You are not closing the TCP connection. Keeping it open will probably cause it to fail because only a few concurrent connections are allowed, maybe you run out of memory, or maybe, you just never exit the outer while loop.

Pieter

Thank you for answer. But if connection fails - does it mean that no commands will be sent anymore? In my case they will but with very strange delay. And on C# application side i don't close connection and don't reopen it (looks like it is all right with connection). About memory - can arduino run out of memory? And why only after 10 minutes pause? At normal state i can send much more commads without lags. Moreover: after this 10 seconds lag all commands will be received. So no losses. Finally about loop - i'm not sure that i wrote it rigth. Maybe some checks are not needed?