// Creates a TSSLSocket from a net.Addr
558704
func NewTSSLSocketFromAddrTimeout(addr net.Addr, cfg *tls.Config, timeout time.Duration) *TSSLSocket {
	return &TSSLSocket{addr: addr, timeout: timeout, cfg: cfg}
}
1294218
func (p *TSSLServerSocket) Open() error {
	if p.IsListening() {
		return NewTTransportException(ALREADY_OPEN, "Server socket already open")
	}
	if l, err := tls.Listen(p.addr.Network(), p.addr.String(), p.cfg); err != nil {
		return err
	} else {
		p.listener = l
	}
	return nil
}
449954
func NewTSocketFromConnTimeout(conn net.Conn, timeout time.Duration) *TSocket {
	return &TSocket{conn: conn, addr: conn.RemoteAddr(), timeout: timeout}
}
30637
func (d CPUDetails) CPUsInSocket(id int) cpuset.CPUSet {
	b := cpuset.NewBuilder()
	for cpu, info := range d {
		if info.SocketID == id {
			b.Add(cpu)
		}
	}
	return b.Result()
}
1162325
func (o *IKEGateway) CreateIKESubnet(child *IKESubnet) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
426052
func NewSubSocket() (*SubSocket, error) {
	s, err := NewSocket(AF_SP, SUB)
	return &SubSocket{s}, err
}
488465
func CreateSocket(mark int, deviceName string) (SocketWriter, error) {
	fd, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_RAW)
	if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_MARK, mark); err != nil {
		syscall.Close(fd) // nolint
		return nil, fmt.Errorf("Received error %s while setting socket Option SO_MARK", err)
	}

	if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_HDRINCL, 1); err != nil {
		syscall.Close(fd) // nolint
		return nil, fmt.Errorf("Received error %s while setting socket Option IP_HDRINCL", err)
	}
	insock := &syscall.SockaddrInet4{
		Port: 0,
	}

	return &rawsocket{
		fd:     fd,
		insock: insock,
	}, nil

}
1226366
func sysctlInitLB(nodeIface, lbIface *net.Interface) error {

	// System level sysctls.
	for _, ctl := range seesawSysctls {
		if _, err := sysctl(ctl.name, ctl.value); err != nil {
			return err
		}
	}

	// Interface level sysctls.
	ifaces := []string{"all", "default", nodeIface.Name, lbIface.Name}
	for _, iface := range ifaces {
		if err := sysctlInitIface(iface); err != nil {
			return err
		}
	}
	return nil
}
701583
func createClientTLSConfig(certBytes []byte, key *ecdsa.PrivateKey) (*tls.Config, error) {
	clientCert, err := x509.ParseCertificate(certBytes)
	if err != nil {
		return nil, errwrap.Wrapf("error parsing generated plugin certificate: {{err}}", err)
	}

	cert := tls.Certificate{
		Certificate: [][]byte{certBytes},
		PrivateKey:  key,
		Leaf:        clientCert,
	}

	clientCertPool := x509.NewCertPool()
	clientCertPool.AddCert(clientCert)

	tlsConfig := &tls.Config{
		Certificates: []tls.Certificate{cert},
		RootCAs:      clientCertPool,
		ClientCAs:    clientCertPool,
		ClientAuth:   tls.RequireAndVerifyClientCert,
		ServerName:   clientCert.Subject.CommonName,
		MinVersion:   tls.VersionTLS12,
	}

	tlsConfig.BuildNameToCertificate()

	return tlsConfig, nil
}
191681
func (c *Client) CreateSAMLConnector(connector services.SAMLConnector) error {
	data, err := services.GetSAMLConnectorMarshaler().MarshalSAMLConnector(connector)
	if err != nil {
		return trace.Wrap(err)
	}
	_, err = c.PostJSON(c.Endpoint("saml", "connectors"), &createSAMLConnectorRawReq{
		Connector: data,
	})
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
1016336
func CreateSecureWebSocketServer(address string, config *tls.Config) (*WebSocketServer, error) {
	listener, err := tls.Listen("tcp", address, config)
	if err != nil {
		return nil, err
	}

	return NewWebSocketServer(listener), nil
}
1162112
func (s *StdoutClient) CreateTCPSocket() error {
	if s.FD == nil {
		s.FD = os.Stdout
	}
	return nil
}
1307536
func NewTSocketTimeout(hostPort string, timeout time.Duration) (*TSocket, error) {
	//conn, err := net.DialTimeout(network, address, timeout)
	addr, err := net.ResolveTCPAddr("tcp", hostPort)
	if err != nil {
		return nil, err
	}
	return NewTSocketFromAddrTimeout(addr, timeout), nil
}
334560
func (r Network_Interconnect_Tenant) CreateConnection(templateObject *datatypes.Network_Interconnect_Tenant) (resp string, err error) {
	params := []interface{}{
		templateObject,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Interconnect_Tenant", "createConnection", params, &r.Options, &resp)
	return
}
1135798
func NewWebSocketService(c *Client) *WebSocketService {
	return &WebSocketService{
		client:     c,
		chanMap:    make(map[float64]chan []float64),
		subscribes: make([]subscribeToChannel, 0),
	}
}
146006
func MTLSListener(addr string, config *tls.Config) (Listener, error) {
	if config == nil {
		config = DefaultTLSConfig
	}
	ln, err := net.Listen("tcp", addr)
	if err != nil {
		return nil, err
	}

	l := &mtlsListener{
		ln:       tls.NewListener(tcpKeepAliveListener{ln.(*net.TCPListener)}, config),
		connChan: make(chan net.Conn, 1024),
		errChan:  make(chan error, 1),
	}
	go l.listenLoop()

	return l, nil
}
1062598
func NewClient(addr string, tlsConfig *tlsconfig.Options) (*Client, error) {
	clientTransport, err := newTransport(addr, tlsConfig)
	if err != nil {
		return nil, err
	}
	return newClientWithTransport(clientTransport, 0), nil
}