Handle socket connection failures properly
authorPat Thoyts <patthoyts@users.sourceforge.net>
Sun, 14 Feb 2010 02:04:37 +0000 (02:04 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Sun, 14 Feb 2010 02:04:37 +0000 (02:04 +0000)
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
lib/irc/picoirc.tcl

index c6429aac98dc9a981e0cacc6e2242a256a3453d3..86c0dad02463854bee94a3cfc9e2c519cac1f1dc 100644 (file)
@@ -118,6 +118,11 @@ proc ::picoirc::SocksConnect {context} {
     global tcl_platform
     upvar #0 $context irc
     fileevent $irc(socket) writable {}
+    if {[set err [fconfigure $irc(socket) -error]] ne ""} {
+        Callback $context close $err
+        catch {close $irc(socket)}
+        return
+    }
     socks5::init $irc(socket) $irc(server) $irc(port) \
         -username $tcl_platform(user) \
         -command [list [namespace origin SocksConnected] $context]