Detecting at run time if network is lost

I have a chat application and i am using ActionScript 3. I am also using PollServer with a 30 secs limit. I want my application to detect network connectivity at run time. The polling stops as soon as i lan wire is taken out of system but it does not throw exception. The IOERROR is thrown when i manually try sending another packet.As soon as the user pulls out his cable, message should be displayed to him that internet connection is lost. How can i catch this event? I have searched and searched but only found for AIR application nothing for Web application. Please help!!!