# File tokyotyrant.rb, line 100
    def open(host, port = 0, timeout = 0)
      host = _argstr(host)
      port = _argnum(port)
      timeout = _argnum(timeout)
      if @sock
        @ecode = EINVALID
        return false
      end
      if port > 0
        begin
          info = TCPSocket::gethostbyname(host)
        rescue Exception
          @ecode = ENOHOST
          return false
        end
        begin
          sock = TCPSocket::open(info[3], port)
        rescue Exception
          @ecode = EREFUSED
          return false
        end
        begin
          sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
        rescue Exception
        end
      else
        begin
          sock = UNIXSocket::open(host)
        rescue Exception
          @ecode = EREFUSED
          return false
        end
      end
      if sock.respond_to?(:set_encoding)
        sock.set_encoding("ASCII-8BIT")
      end
      @sock = sock
      @tout = timeout
      return true
    end