]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/ircsocket.rb
better failure to connect behaviour
[user/henk/code/ruby/rbot.git] / lib / rbot / ircsocket.rb
index af605e371962eedd69bfd19480751d2153d8d875..7ceba21b91858664c4b2644ccced8c0f7f97f625 100644 (file)
@@ -31,6 +31,7 @@ module Irc
       @server = server.dup
       @port = port.to_i
       @host = host
+      @sock = nil
       @spooler = false
       @lines_sent = 0
       @lines_received = 0
@@ -50,6 +51,7 @@ module Irc
     
     # open a TCP connection to the server
     def connect
+      @sock = nil
       if(@host)
         begin
           @sock=TCPSocket.new(@server, @port, @host)
@@ -165,7 +167,8 @@ module Irc
 
     # shutdown the connection to the server
     def shutdown(how=2)
-      @sock.shutdown(how)
+      @sock.shutdown(how) unless @sock.nil?
+      @sock = nil
     end
 
     private