// NewConnection returns a new CloudControllerConnection with provided
// configuration.
772603
func NewConnection(config Config) *CloudControllerConnection {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: config.SkipSSLValidation,
		},
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			KeepAlive: 30 * time.Second,
			Timeout:   config.DialTimeout,
		}).DialContext,
	}

	return &CloudControllerConnection{
		HTTPClient: &http.Client{Transport: tr},
	}
}
715588
func newConnection(address string, timeout time.Duration) (*Connection, error) {
	newConn := &Connection{dataBuffer: make([]byte, DefaultBufferSize)}
	runtime.SetFinalizer(newConn, connectionFinalizer)

	// don't wait indefinitely
	if timeout == 0 {
		timeout = 5 * time.Second
	}

	conn, err := net.DialTimeout("tcp", address, timeout)
	if err != nil {
		Logger.Error("Connection to address `" + address + "` failed to establish with error: " + err.Error())
		return nil, errToTimeoutErr(nil, err)
	}
	newConn.conn = conn

	// set timeout at the last possible moment
	if err := newConn.SetTimeout(time.Now().Add(timeout), timeout); err != nil {
		newConn.Close()
		return nil, err
	}

	return newConn, nil
}
79655
func (r *AttachREST) NewConnectOptions() (runtime.Object, bool, string) {
	return &api.PodAttachOptions{}, false, ""
}
1089275
func NewConnectionEvent(connected bool, err DisconnectedError) *ConnectionEvent {
	return &ConnectionEvent{Connected: connected, Err: err}
}
1104560
func newAuthenticatedConnection(conn driver.Connection, auth httpAuthentication) (driver.Connection, error) {
	if conn == nil {
		return nil, driver.WithStack(driver.InvalidArgumentError{Message: "conn is nil"})
	}
	if auth == nil {
		return nil, driver.WithStack(driver.InvalidArgumentError{Message: "auth is nil"})
	}
	return &authenticatedConnection{
		conn: conn,
		auth: auth,
	}, nil
}
1150395
func (c *Transport) createConnection() (*Connection, error) {
	conn, err := dial(c.Version, c.hostAddr, c.tlsConfig)
	if err != nil {
		return nil, driver.WithStack(err)
	}

	// Record connection
	c.connMutex.Lock()
	c.connections = append(c.connections, conn)
	startCleanup := len(c.connections) == 1
	c.connMutex.Unlock()

	if startCleanup {
		// TODO enable cleanup
		go c.cleanup()
	}

	return conn, nil
}
390842
func NewConnector(svrAddr string, opts ...ClientOption) IOSession {
	sopts := &clientOptions{}
	for _, opt := range opts {
		opt(sopts)
	}
	sopts.adjust()

	return &connector{
		addr:  svrAddr,
		in:    NewByteBuf(sopts.readBufSize),
		out:   NewByteBuf(sopts.writeBufSize),
		opts:  sopts,
		attrs: make(map[string]interface{}),
	}
}
1222416
func NewMockInstanceConnector(ctrl *gomock.Controller) *MockInstanceConnector {
	mock := &MockInstanceConnector{ctrl: ctrl}
	mock.recorder = &MockInstanceConnectorMockRecorder{mock}
	return mock
}
327495
func NewMConnection(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc) *MConnection {
	return NewMConnectionWithConfig(
		conn,
		chDescs,
		onReceive,
		onError,
		DefaultMConnConfig())
}
417015
func NewI2CConnection(i2c embd.I2CBus, addr byte, pinMap I2CPinMap) *I2CConnection {
	return &I2CConnection{
		I2C:    i2c,
		Addr:   addr,
		PinMap: pinMap,
	}
}
899794
func NewConnection(skipSSLValidation bool, dialTimeout time.Duration) *PluginConnection {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: skipSSLValidation,
		},
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			KeepAlive: 30 * time.Second,
			Timeout:   dialTimeout,
		}).DialContext,
	}

	return &PluginConnection{
		HTTPClient: &http.Client{Transport: tr},
	}
}
572444
func newParsedConnection(namespace, suffix, hubName, keyName, key string) *ParsedConn {
	return &ParsedConn{
		Host:      "amqps://" + namespace + "." + suffix,
		Suffix:    suffix,
		Namespace: namespace,
		KeyName:   keyName,
		Key:       key,
		HubName:   hubName,
	}
}
153897
func newConnection(network, address string, tlsConfig *tls.Config) (*connection, error) {
	// Define the local variables.
	var conn net.Conn
	var err error

	// Connect to the address on the named network.
	if tlsConfig != nil {
		conn, err = tls.Dial(network, address, tlsConfig)
	} else {
		conn, err = net.Dial(network, address)
	}
	if err != nil {
		return nil, err
	}

	// Create a Network Connection.
	c := &connection{
		Conn:      conn,
		r:         bufio.NewReader(conn),
		w:         bufio.NewWriter(conn),
		connack:   make(chan struct{}, 1),
		send:      make(chan packet.Packet, sendBufSize),
		sendEnd:   make(chan struct{}, 1),
		unackSubs: make(map[string]MessageHandler),
		ackedSubs: make(map[string]MessageHandler),
	}

	// Return the Network Connection.
	return c, nil
}
1294018
func NewConnection(opts ...clientmocks.Opt) *MockConnection {
	return &MockConnection{
		MockConnection: *clientmocks.NewMockConnection(opts...),
	}
}
27114
func NewSystemConnection() (*Conn, error) {
	return NewConnection(func() (*dbus.Conn, error) {
		return dbusAuthHelloConnection(dbus.SystemBusPrivate)
	})
}
1123543
func NewConn(host string, port int, poolsize int, timeout time.Duration) (*Conn, error) {
	return newConn(host, port, poolsize, timeout, "")
}
951124
func NewAsynchConnection(spec *ConnectionSpec) (conn AsyncConnection, err Error) {
	defer func() {
		if e := recover(); e != nil {
			connerr := e.(error)
			err = newSystemErrorWithCause("NewSyncConnection", connerr)
		}
	}()

	//	var async *asyncConnHdl
	async := newAsyncConnHdl(spec)
	async.connect()
	async.startup()

	conn = async
	return
}