// Dial establishes a connection to Qlik Associative Engine using the settings set in the Dialer. It takes two parameter
427256
func (dialer Dialer) Dial(ctx context.Context, url string, httpHeader http.Header) (*Global, error) {
	// Set empty http header if omitted
	if httpHeader == nil {
		httpHeader = make(http.Header, 0)
	}

	if dialer.MockMode {
		dialer.CreateSocket = func(ctx context.Context, url string, httpHeader http.Header) (Socket, error) {
			socket, err := NewMockSocket(dialer.TrafficDumpFile)
			return socket, err
		}
	} else {
		// Create default CreateSocket function if omitted
		if dialer.CreateSocket == nil {
			dialer.CreateSocket = func(ctx context.Context, url string, httpHeader http.Header) (Socket, error) {
				gorillaDialer := websocket.Dialer{
					TLSClientConfig: dialer.TLSClientConfig,
					NetDial: func(network, addr string) (net.Conn, error) {
						return (&net.Dialer{}).DialContext(ctx, network, addr)
					},
					Jar: dialer.Jar,
				}

				// Run the actual websocket dialing (including the upgrade) in a goroutine so we can
				// return if the context times out
				chConn := make(chan *websocket.Conn, 1)
				chErr := make(chan error, 1)
				go func() {
					conn, resp, err := gorillaDialer.Dial(url, httpHeader)
					if err == websocket.ErrBadHandshake {
						chErr <- errors.Wrapf(err, "%d from ws server", resp.StatusCode)
					} else if err != nil {
						chErr <- err
					} else {
						select {
						case <-ctx.Done():
							conn.Close()
						default:
							chConn <- conn
						}
					}
				}()
				select {
				case <-ctx.Done():
					return nil, errors.Wrapf(ctx.Err(), "error connecting to ws server %s", url)
				case err := <-chErr:
					return nil, err
				case ws := <-chConn:
					return ws, nil
				}
			}
		}
		if dialer.TrafficDumpFile != "" {
			dialer.TrafficLogger = newFileTrafficLogger(dialer.TrafficDumpFile)
		}
	}

	enigmaSession := newSession(&dialer)
	err := enigmaSession.connect(ctx, url, httpHeader)
	if err != nil {
		return nil, err
	}
	return &Global{RemoteObject: enigmaSession.getRemoteObject(&ObjectInterface{Handle: -1, Type: "Global"})}, nil
}
598247
func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
	return d.DialContext(context.Background(), urlStr, requestHeader)
}
685177
func Dial(network, addr string) (*Conn, error) {
	return DialTimeout(network, addr, DefaultDialTimeout)
}
891762
func Dial(addr string, TLS *tls.Config) (Conn, error) {
	if addr == "" {
		addr = "localhost:2775"
	}
	fd, err := net.Dial("tcp", addr)
	if err != nil {
		return nil, err
	}
	if TLS != nil {
		fd = tls.Client(fd, TLS)
	}
	c := &conn{
		rwc: fd,
		r:   bufio.NewReader(fd),
		w:   bufio.NewWriter(fd),
	}
	return c, nil
}
220174
func (w *Worker) Dial(o DialOptions) {
	// Create task
	t := w.NewTask()

	// Execute the rest in a goroutine
	go func() {
		// Dial
		go func() {
			const sleepError = 5 * time.Second
			for {
				// Check context error
				if w.ctx.Err() != nil {
					break
				}

				// Dial
				astilog.Infof("astiworker: dialing %s", o.Addr)
				if err := o.Client.DialWithHeaders(o.Addr, o.Header); err != nil {
					astilog.Error(errors.Wrapf(err, "astiworker: dialing %s failed", o.Addr))
					time.Sleep(sleepError)
					continue
				}

				// Custom callback
				if o.OnDial != nil {
					if err := o.OnDial(); err != nil {
						astilog.Error(errors.Wrapf(err, "astiworker: custom on dial callback on %s failed", o.Addr))
						time.Sleep(sleepError)
						continue
					}
				}

				// Read
				if err := o.Client.Read(); err != nil {
					if o.OnReadError != nil {
						o.OnReadError(err)
					} else {
						astilog.Error(errors.Wrapf(err, "astiworker: reading on %s failed", o.Addr))
					}
					time.Sleep(sleepError)
					continue
				}
			}
		}()

		// Wait for context to be done
		<-w.ctx.Done()

		// Close client
		if err := o.Client.Close(); err != nil {
			astilog.Error(errors.Wrapf(err, "astiworker: closing dial on %s failed", o.Addr))
		}

		// Task is done
		t.Done()
	}()

}
2012
func Dial(hsAddress string) (*grpc.ClientConn, error) {
	mu.Lock()
	defer mu.Unlock()

	if hsConn == nil {
		// Create a new connection to the handshaker service. Note that
		// this connection stays open until the application is closed.
		var err error
		hsConn, err = hsDialer(hsAddress, grpc.WithInsecure())
		if err != nil {
			return nil, err
		}
	}
	return hsConn, nil
}
1191222
func (d *Dialer) Dial(n, addr string) (*Conn, error) {
	raddr, err := ResolveAddr(n, addr)
	if err != nil {
		return nil, err
	}

	var laddr *Addr
	if d.LocalAddr != nil {
		var ok bool
		laddr, ok = d.LocalAddr.(*Addr)
		if !ok {
			return nil, errors.New("Dialer.LocalAddr is not a Addr")
		}
	}

	return DialUTPTimeout(n, laddr, raddr, d.Timeout)
}
449178
func Dial(etcdURI string) (EtcdClient, error) {
	etcd, err := client.New(client.Config{
		Endpoints: []string{etcdURI},
	})
	if err != nil {
		return nil, err
	}
	return &SimpleEtcdClient{etcd}, nil
}
122499
func Dial(url string, sessionNum int) (*DialContext, error) {
	c, err := DialWithTimeout(url, sessionNum, 10*time.Second, 5*time.Minute)
	return c, err
}
1253271
func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) {
	host, _, err := net.SplitHostPort(addr)
	if err != nil {
		return nil, err
	}

	return p.dialerForRequest(host).Dial(network, addr)
}
276989
func Dial(addr, server string, cipher *Cipher) (c *Conn, err error) {
	ra, err := RawAddr(addr)
	if err != nil {
		return
	}
	return DialWithRawAddr(ra, server, cipher)
}
599359
func Dial(network, address string) (fcgi *FCGIClient, err error) {
	return DialContext(context.Background(), network, address)
}
849929
func (s *remoteSite) Dial(params DialParams) (net.Conn, error) {
	err := params.CheckAndSetDefaults()
	if err != nil {
		return nil, trace.Wrap(err)
	}

	clusterConfig, err := s.localAccessPoint.GetClusterConfig()
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// if the proxy is in recording mode use the agent to dial and build a
	// in-memory forwarding server
	if clusterConfig.GetSessionRecording() == services.RecordAtProxy {
		if params.UserAgent == nil {
			return nil, trace.BadParameter("user agent missing")
		}
		return s.dialWithAgent(params)
	}
	return s.DialTCP(params.From, params.To)
}
930981
func Dial(ctx context.Context, urlstr string) (net.Conn, *bufio.Reader, Handshake, error) {
	return DefaultDialer.Dial(ctx, urlstr)
}
1153318
func Dial(network, address string, options ...DialOption) (Conn, error) {
	do := dialOptions{
		dialer: &net.Dialer{
			KeepAlive: time.Minute * 5,
		},
	}
	for _, option := range options {
		option.f(&do)
	}
	if do.dial == nil {
		do.dial = do.dialer.Dial
	}

	netConn, err := do.dial(network, address)
	if err != nil {
		return nil, err
	}

	if do.useTLS {
		var tlsConfig *tls.Config
		if do.tlsConfig == nil {
			tlsConfig = &tls.Config{InsecureSkipVerify: do.skipVerify}
		} else {
			tlsConfig = cloneTLSConfig(do.tlsConfig)
		}
		if tlsConfig.ServerName == "" {
			host, _, err := net.SplitHostPort(address)
			if err != nil {
				netConn.Close()
				return nil, err
			}
			tlsConfig.ServerName = host
		}

		tlsConn := tls.Client(netConn, tlsConfig)
		if err := tlsConn.Handshake(); err != nil {
			netConn.Close()
			return nil, err
		}
		netConn = tlsConn
	}

	c := &conn{
		conn:         netConn,
		bw:           bufio.NewWriter(netConn),
		br:           bufio.NewReader(netConn),
		readTimeout:  do.readTimeout,
		writeTimeout: do.writeTimeout,
	}

	if do.password != "" {
		if _, err := c.Do("AUTH", do.password); err != nil {
			netConn.Close()
			return nil, err
		}
	}

	if do.clientName != "" {
		if _, err := c.Do("CLIENT", "SETNAME", do.clientName); err != nil {
			netConn.Close()
			return nil, err
		}
	}

	if do.db != 0 {
		if _, err := c.Do("SELECT", do.db); err != nil {
			netConn.Close()
			return nil, err
		}
	}

	return c, nil
}
135429
func Dial(ctx context.Context, address string) (*VTGateConn, error) {
	return DialProtocol(ctx, *VtgateProtocol, address)
}
477367
func Dial(client *http.Client, ua string, token client.Token, u *url.URL) (Websocket, error) {
	// Build the http request
	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return nil, errors.Wrapf(err, "constructing request %s", u)
	}

	// Send version in user-agent
	req.Header.Set("User-Agent", ua)

	// Add authentication if provided
	token.Set(req)

	// Use http client to do the http request
	conn, resp, err := dialer(client).Dial(u.String(), req.Header)
	if err != nil {
		if resp != nil {
			err = &DialErr{u, resp}
		}
		return nil, err
	}

	// Set up the ping heartbeat
	return Ping(conn), nil
}