Arduino gives up / Flooding ethershield?

Hello SurferTim:

Looks like it dies on opening a new connection. I modified the client.connected while loop to print a message on failed connection as that was the only place where it goes into an endless (halted) loop without flashing an LED and sure enough, that was the location where it was dying.

After some additional testing, it appears that the ethershield IS flooding the server. During a locked/poll session, the device should be phoning home every few seconds to see if it needs to change state. I did some digging around and found that just before the Arduino halted, I had over 200 incoming HTTP connections from the Arduino's IP. It appears that the Wiznet can only support so many connections and when too many connections are open, it will cause client.connect to fail. :blush:

Every 1.0s: netstat -an | grep tcp | grep 80                                                                                                                                               Thu Aug 30 16:06:39 2012

tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 172.16.222.100:80       172.16.222.160:1027     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1058     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1038     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1045     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1043     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1066     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1044     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1061     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1056     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1057     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1051     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1048     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1062     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1042     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1055     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1039     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1060     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1053     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1036     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1029     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1041     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1034     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1037     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1030     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1067     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1033     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1032     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1059     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1065     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1052     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1047     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1050     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1064     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1025     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1031     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1040     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1054     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1035     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1046     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1028     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1063     TIME_WAIT
tcp6       0      0 172.16.222.100:80       172.16.222.160:1049     TIME_WAIT

I guess the big question now is how can I tell the Arduino to only phone home once every 30sec or so and still be able to read cards in between pollings? Because it has to be able to read a card, I think that delay(5000) is out?