CLIENT/SERVER - I don't receive all the data from the server!

Hi everybody…please help me! :confused:
I have two sketches ( a client and a server).

The client makes a request to the server, and the server must send to the client all the text from a file present in SD card.

THE PROBLEM IS:
the client doesn’t receive all the data from the server!!
The client receives a part of the message.

Should I set a function for a timeout?? or not?

p.s.
Client is a WifiShield
Server is a EthernetShield.

client.ino (2.35 KB)

server.ino (1.71 KB)

For posting code, #7 below:

http://forum.arduino.cc/index.php/topic,148850.0.html

Your client code is not waiting for the server to close the connection. That is the signal the server is finished sending packets. This has no timeout feature, so it is vulnerable to locking up if the server stalls or the connectio0n breaks.

while(client.connected())
{
   while (client.available())
   {  
      c= client.read();      
      Serial.print(c);
      myFile.print(c);
   }
}
                          
myFile.close();
client.stop();

Here is a client example with the timeout feature. http://playground.arduino.cc/Code/WebClient