// Dial establishes a connection to the Seesaw Engine.
423996
func (c *engineRPC) Dial(addr string) error {
	// TODO(jsing): Configure CA certificate chain and disable insecure
	// skip verify.
	tlsConfig := &tls.Config{
		InsecureSkipVerify: true,
	}
	conn, err := tls.Dial("tcp", addr, tlsConfig)
	if err != nil {
		return fmt.Errorf("Dial failed: %v", err)
	}
	c.conn = conn
	c.client = rpc.NewClient(conn)
	c.ctx.Peer.Identity = fmt.Sprintf("tcp %s", c.conn.LocalAddr())
	return nil
}
55337
func (p *Process) Dial(addr string, path string, pid int, debugInfoDirs []string) error {
	for {
		conn, err := net.Dial("tcp", addr)
		if err == nil {
			return p.Connect(conn, path, pid, debugInfoDirs)
		}
		select {
		case status := <-p.waitChan:
			return fmt.Errorf("stub exited while attempting to connect: %v", status)
		default:
		}
		time.Sleep(time.Second)
	}
}
349612
func (r *ClearNet) Dial(network, address string) (net.Conn, error) {
	return net.Dial(network, address)
}
412900
func Dial(socket string) (net.Conn, error) {
	conn, err := winio.DialPipe(defaults.WindowsOpenSSHNamedPipe, nil)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return conn, nil
}
485334
func Dial(network, addr string) (*Client, error) {
	return DialTimeout(network, addr, time.Duration(0))
}
832225
func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
	var logdial = lgbl.Dial("swarm", s.LocalPeer(), p, nil, nil)
	if p == s.local {
		log.Event(ctx, "swarmDialDoDialSelf", logdial)
		return nil, ErrDialToSelf
	}
	defer log.EventBegin(ctx, "swarmDialDo", logdial).Done()
	logdial["dial"] = "failure" // start off with failure. set to "success" at the end.

	sk := s.peers.PrivKey(s.local)
	logdial["encrypted"] = sk != nil // log whether this will be an encrypted dial or not.
	if sk == nil {
		// fine for sk to be nil, just log.
		log.Debug("Dial not given PrivateKey, so WILL NOT SECURE conn.")
	}

	//////
	/*
		This slice-to-chan code is temporary, the peerstore can currently provide
		a channel as an interface for receiving addresses, but more thought
		needs to be put into the execution. For now, this allows us to use
		the improved rate limiter, while maintaining the outward behaviour
		that we previously had (halting a dial when we run out of addrs)
	*/
	peerAddrs := s.peers.Addrs(p)
	if len(peerAddrs) == 0 {
		return nil, &DialError{Peer: p, Cause: ErrNoAddresses}
	}
	goodAddrs := s.filterKnownUndialables(peerAddrs)
	if len(goodAddrs) == 0 {
		return nil, &DialError{Peer: p, Cause: ErrNoGoodAddresses}
	}
	goodAddrsChan := make(chan ma.Multiaddr, len(goodAddrs))
	for _, a := range goodAddrs {
		goodAddrsChan <- a
	}
	close(goodAddrsChan)
	/////////

	// try to get a connection to any addr
	connC, dialErr := s.dialAddrs(ctx, p, goodAddrsChan)
	if dialErr != nil {
		logdial["error"] = dialErr.Cause.Error()
		if dialErr.Cause == context.Canceled {
			// always prefer the "context canceled" error.
			// we rely on behing able to check `err == context.Canceled`
			//
			// Removing this will BREAK backoff (causing us to
			// backoff when canceling dials).
			return nil, context.Canceled
		}
		return nil, dialErr
	}
	logdial["conn"] = logging.Metadata{
		"localAddr":  connC.LocalMultiaddr(),
		"remoteAddr": connC.RemoteMultiaddr(),
	}
	swarmC, err := s.addConn(connC, inet.DirOutbound)
	if err != nil {
		logdial["error"] = err.Error()
		connC.Close() // close the connection. didn't work out :(
		return nil, &DialError{Peer: p, Cause: err}
	}

	logdial["dial"] = "success"
	return swarmC, nil
}
1227097
func (t TCPDialer) Dial(dest *enode.Node) (net.Conn, error) {
	addr := &net.TCPAddr{IP: dest.IP(), Port: dest.TCP()}
	return t.Dialer.Dial("tcp", addr.String())
}
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
}
230927
func (d *Dialer) Dial(remote ma.Multiaddr) (Conn, error) {
	return d.DialContext(context.Background(), remote)
}
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
}
1094169
func Dial(addr string) (*Client, error) {
	conn, err := net.Dial("tcp", addr)
	if err != nil {
		return nil, err
	}
	host, _, _ := net.SplitHostPort(addr)
	return NewClient(conn, host)
}
289260
func Dial(cfg *DialConfig) (*Redis, error) {
	if cfg == nil {
		cfg = &DialConfig{}
	}
	if cfg.Network == "" {
		cfg.Network = DefaultNetwork
	}
	if cfg.Address == "" {
		cfg.Address = DefaultAddress
	}
	if cfg.Timeout == 0 {
		cfg.Timeout = DefaultTimeout
	}
	if cfg.MaxIdle == 0 {
		cfg.MaxIdle = DefaultMaxIdle
	}
	r := &Redis{
		network:  cfg.Network,
		address:  cfg.Address,
		db:       cfg.Database,
		password: cfg.Password,
		timeout:  cfg.Timeout,
	}
	r.pool = &connPool{
		MaxIdle: cfg.MaxIdle,
		Dial:    r.dialConnection,
		idle:    list.New(),
	}
	conn, err := r.dialConnection()
	if err != nil {
		return nil, err
	}
	r.pool.Put(conn)
	return r, nil
}
884832
func (c *Client) Dial(n, addr string) (net.Conn, error) {
	// Parse the address into host and numeric port.
	host, portString, err := net.SplitHostPort(addr)
	if err != nil {
		return nil, err
	}
	port, err := strconv.ParseUint(portString, 10, 16)
	if err != nil {
		return nil, err
	}
	// Use a zero address for local and remote address.
	zeroAddr := &net.TCPAddr{
		IP:   net.IPv4zero,
		Port: 0,
	}
	ch, err := c.dial(net.IPv4zero.String(), 0, host, int(port))
	if err != nil {
		return nil, err
	}
	return &tcpChanConn{
		Channel: ch,
		laddr:   zeroAddr,
		raddr:   zeroAddr,
	}, nil
}
296295
func (p *Pool) Dial(address string) error {
	if p.RequestTimeout <= 0 {
		p.RequestTimeout = 10 * time.Second
	}
	if p.InitialConn <= 0 {
		p.InitialConn = Config.PoolInitialSize
	}
	if p.MaximumConn <= 0 {
		p.MaximumConn = Config.PoolMaximumSize
	}
	if p.MaximumConn < p.InitialConn {
		p.MaximumConn = p.InitialConn
	}
	p.l = list.New()
	p.mutex = &sync.Mutex{}
	p.cond = sync.NewCond(p.mutex)
	p.address = address
	return p.connect(0)
}
1147890
func (l *streamLayer) Dial(addr raft.ServerAddress, timeout time.Duration) (net.Conn, error) {
	return l.dialer.Dial(addr, timeout)
}
825770
func (d *Dialer) Dial(network, address string) (net.Conn, error) {
	return d.DialContext(context.Background(), network, address)
}
437054
func Dial(addr string, options ...DialOption) (net.Conn, error) {
	return DefaultClient.Dial(addr, options...)
}