I don't know if is it stated anywhere with this clearance, but here is the source code for detecting the connection abort/closure for sockets testing with socket_read function:
<?php
$buf = @socket_read($routes[$i][$connectionid]['tunnelsrc'], $buffer_size);
if ($buf === '')
{
$routes[$i][$connectionid]['disconnected']='Conenction abort at source side';
}
?>
($buf === '') is the key :)
I was making an ecrypted tunnel script with mcrypt and was annoying that i could not detect the connection abort from any side.