$sockerr
From Scriptwiki
$sockerr
$sockerr is set to a value after each socket command/event and must be checked after each socket command and before processing an event to see if an error occurred.
$sockerr returning 3 = "Connection refused by remote host"
$sockerr returning 4 = "DNS lookup for hostname failed"