How can I prevent my Wi-Fi connection from glitching? Occassionally my Wi-Fi goes into this weird state where the phone "thinks" I'm connected, but the connection simply doesn't work.  Apps still seem to think I have connectivity, though they can't actually connect to anything, and the status bar still shows that I'm connected to Wi-Fi.  Turning Wi-Fi off and back on resolves the issue, and this occurs on multiple networks.

It seems sort of like whatever service manages the Wi-Fi connection gets killed occasionally.  It usually happens when I've been playing a game (that doesn't access the Internet) for a while or if my phone's been sitting for a while; it never happens while I'm actively using the connection.  I have my Wi-Fi timeout set to "Never" and the normal timeout isn't the issue since my phone regularly lasts several hours without the Wi-Fi dying.  Sometimes it dies a couple times in a day, and recently I went a week or so without it happening.

How can I fix this or prevent the service from being killed (if that's indeed what's happening)?  Shouldn't that be a system process that never gets killed?  (Does Android ever kill system processes other than when they crash?)  Could it be related to TouchWiz?  I have an SGS Vibrant running 2.2 (Bionix NextGen v1, but this has occurred on multiple ROMs).
This could be a solution, but it's more a hint at the issue:

The ZTE Blade suffers with losing it's Wi-Fi connection when it comes back from sleep. Perhaps you have a similar issue?
The app Blade Wifi Fix by AA Android available from Google Play Store, fixes it on the Blade, you could give it a try:


  Some people with the ZTE Blade / Orange San Francisco phone find that the Wifi doesn't always come back on after the phone wakes up from being locked or asleep.
  
  Install this and you wont know its there until you wake up your phone and the Wifi jams, at which point it will flash a message to tell you its fixing it.