Wifi Shield stops sending after sometime.

To sum up what I found during a week of trying to debug the WiFi problem, if you use server code, expect it to run for 6 minutes up to 2 hours once the server is called to the point that it becomes unresponsive.

I found putting and using booleans in certain places when certain code is written increases the time until the crash by a little bit, which suggest an overflow problem. This overflow problem was not from the code I wrote, and seems to be caused in the WiFi firmware.

Interestingly, if you use the server it causes the crash relatively quickly, if you have server code in the program but it is never called, it will not freeze. Even more interesting, is that server almost always crashes the arduino once called within 20 minutes, client code crashes the arduino once called as well, but it usually takes a few hours and is not nearly as quick to crash as the server code. Either way, your arduino will not run two days without crashing if client or server code is called.

Post 30 of the link I provided on the post above provides even more diagnostics from another person.

Sorry to break this to you but you are playing with inherently broken hardware.

This thread has the most complete summary of the many issues affecting the WiFi shields TCP communication.
Official Arduino WiFi Shield - Issues - Improvements - Call to action - Networking, Protocols, and Devices - Arduino Forum

I also did some experimenting myself.
emscom Help Desk

I think at one point I tried calling the server code, then unattached the wifi shield before the crash accorded. Interestingly, that didn't stop the crash. I am confident that the problem is in the wifi firmware, which no one ever really looks into.

For convience, the url links he mentioned are provided here

http://forum.arduino.cc/index.php?topic=128424.0

http://mssystems.emscom.net/helpdesk/knowledgebase.php?article=51