Detect Connection Abort or Disconnect

In PHP's fsockopen there is no direct way to detect the cause of disconnection.
The problem is that the script will keep up and running EVEN IF YOU UNPLUGGED YOUR NETWORK!
This condition will check if there is still connectivity to the server before attempting to read any data.