# File lib/phusion_passenger/admin_tools/server_instance.rb, line 192
        def connect(options)
                if options[:role]
                        username, password, default_socket_name = infer_connection_info_from_role(options[:role])
                        socket_name = options[:socket_name] || default_socket_name
                else
                        username = options[:username]
                        password = options[:password]
                        socket_name = options[:socket_name] || "helper_admin"
                        raise ArgumentError, "Either the :role or :username must be set" if !username
                        raise ArgumentError, ":password must be set" if !password
                end
                
                client = MessageClient.new(username, password, "unix:#{@generation_path}/#{socket_name}")
                if block_given?
                        begin
                                yield client
                        ensure
                                client.close
                        end
                else
                        return client
                end
        end