Basically I need an Event for when your internet connection goes on, and off

Or just a way to detect if its on or off, my game will use a chat & a mySQL database, and basically you can't play without internet connection

So, does anyone know how? and if so give an example please and thankyou