// VerifyTCP verifies if a port is available on TCP
554252
func VerifyTCP(port int) (verifiedPort int, err error) {
	ln, err := newListenerTCP(port)
	if err != nil {
		return 0, err
	}
	defer ln.Close()

	return port, nil
}
409055
func (m *MockRPCServer) CheckValidity(req *rpcwrapper.Request, secret string) bool {
	ret := m.ctrl.Call(m, "CheckValidity", req, secret)
	ret0, _ := ret[0].(bool)
	return ret0
}
397997
func (s *Server) ServeTCP(l net.Listener) error {
	grpc_prometheus.Register(s.tcpServer)
	return trapClosedConnErr(s.tcpServer.Serve(l))
}
699634
func (s *SimpleMonitor) SetHealthCheckTCP(port string) {
	s.Settings.SimpleMonitor.HealthCheck = &SimpleMonitorHealthCheck{
		Protocol: "tcp",
		Port:     port,
	}
}
1056449
func VerifyCertificate(cert *x509.Certificate) (revoked, ok bool) {
	revoked, ok, _ = VerifyCertificateError(cert)
	return revoked, ok
}
586356
func (c *Client) VerifyMessageAsync(address btcutil.Address, signature, message string) FutureVerifyMessageResult {
	addr := address.EncodeAddress()
	cmd := btcjson.NewVerifyMessageCmd(addr, signature, message)
	return c.sendCmd(cmd)
}
979106
func (c *CheckTCP) check() {
	var currentStatus string
	previousStatus := c.Status

	conn, err := c.dialer.Dial(`tcp`, c.tcp)
	if err != nil {
		logrus.Warnf("[health-check] TCP Check is failing => %s", err)
		currentStatus = BAD
	} else {
		logrus.Debugf("[health-check] TCP check on '%v' at '%s' is passing", c.DestinationID, c.tcp)
		currentStatus = OK
		conn.Close()
	}

	if currentStatus != previousStatus {
		c.Status = currentStatus
		c.updateCh <- true
	}
}
287706
func proxyTCP(in, out *net.TCPConn) {
	var wg sync.WaitGroup
	wg.Add(2)
	klog.V(4).Infof("Creating proxy between %v <-> %v <-> %v <-> %v",
		in.RemoteAddr(), in.LocalAddr(), out.LocalAddr(), out.RemoteAddr())
	go copyBytes("from backend", in, out, &wg)
	go copyBytes("to backend", out, in, &wg)
	wg.Wait()
}
302791
func DialTCP(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*Conn, error) {
	// Create TCP endpoint, then connect.
	var wq waiter.Queue
	ep, err := s.NewEndpoint(tcp.ProtocolNumber, network, &wq)
	if err != nil {
		return nil, errors.New(err.String())
	}

	// Create wait queue entry that notifies a channel.
	//
	// We do this unconditionally as Connect will always return an error.
	waitEntry, notifyCh := waiter.NewChannelEntry(nil)
	wq.EventRegister(&waitEntry, waiter.EventOut)
	defer wq.EventUnregister(&waitEntry)

	err = ep.Connect(addr)
	if err == tcpip.ErrConnectStarted {
		<-notifyCh
		err = ep.GetSockOpt(tcpip.ErrorOption{})
	}
	if err != nil {
		ep.Close()
		return nil, &net.OpError{
			Op:   "connect",
			Net:  "tcp",
			Addr: fullToTCPAddr(addr),
			Err:  errors.New(err.String()),
		}
	}

	return NewConn(&wq, ep), nil
}
1036390
func (s *Server) IsPortOpen(hostAndPort string) bool {
	portOpen := false
	conn, err := net.Dial("tcp", hostAndPort)
	if err == nil {
		portOpen = true
		defer conn.Close()
	}
	return portOpen
}
34724
func dialTCP(network, addr string, timeout time.Duration, mark int) (nc net.Conn, err error) {
	host, port, err := net.SplitHostPort(addr)
	if err != nil {
		return nil, err
	}
	ip := net.ParseIP(host)
	if ip == nil {
		return nil, fmt.Errorf("invalid IP address %q", host)
	}
	p, err := strconv.ParseUint(port, 10, 16)
	if err != nil {
		return nil, fmt.Errorf("invalid port number %q", port)
	}

	var domain int
	var rsa syscall.Sockaddr
	switch network {
	case "tcp4":
		domain = syscall.AF_INET
		if ip.To4() == nil {
			return nil, fmt.Errorf("invalid IPv4 address %q", host)
		}
		sa := &syscall.SockaddrInet4{Port: int(p)}
		copy(sa.Addr[:], ip.To4())
		rsa = sa

	case "tcp6":
		domain = syscall.AF_INET6
		if ip.To4() != nil {
			return nil, fmt.Errorf("invalid IPv6 address %q", host)
		}
		sa := &syscall.SockaddrInet6{Port: int(p)}
		copy(sa.Addr[:], ip.To16())
		rsa = sa

	default:
		return nil, fmt.Errorf("unsupported network %q", network)
	}

	c := &conn{}

	defer func() {
		if err != nil {
			c.Close()
		}
	}()

	c.fd, err = syscall.Socket(domain, syscall.SOCK_STREAM|syscall.SOCK_CLOEXEC, 0)
	if err != nil {
		return nil, os.NewSyscallError("socket", err)
	}

	if mark != 0 {
		if err := setSocketMark(c.fd, mark); err != nil {
			return nil, err
		}
	}

	if err := setSocketTimeout(c.fd, timeout); err != nil {
		return nil, err
	}
	if err := syscall.Connect(c.fd, rsa); err != nil {
		return nil, os.NewSyscallError("connect", err)
	}
	if err := setSocketTimeout(c.fd, 0); err != nil {
		return nil, err
	}

	lsa, _ := syscall.Getsockname(c.fd)
	rsa, _ = syscall.Getpeername(c.fd)
	name := fmt.Sprintf("%s %s -> %s", network, sockaddrToString(lsa), sockaddrToString(rsa))
	c.f = os.NewFile(uintptr(c.fd), name)

	// When we call net.FileConn the socket will be made non-blocking and
	// we will get a *net.TCPConn in return. The *os.File needs to be
	// closed in addition to the *net.TCPConn when we're done (conn.Close
	// takes care of that for us).
	if c.Conn, err = net.FileConn(c.f); err != nil {
		return nil, err
	}
	if _, ok := c.Conn.(*net.TCPConn); !ok {
		return nil, fmt.Errorf("%T is not a *net.TCPConn", c.Conn)
	}

	return c, nil
}
384786
func (c *Client) VerifyClient() error {
	// If we don't have a client yet, we should try to create one
	if c.client == nil {
		err := c.Connect()
		if err != nil {
			return err
		}
	}

	return nil
}
1221210
func (csp *impl) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (bool, error) {
	// Validate arguments
	if k == nil {
		return false, errors.New("Invalid Key. It must not be nil")
	}
	if len(signature) == 0 {
		return false, errors.New("Invalid signature. Cannot be empty")
	}
	if len(digest) == 0 {
		return false, errors.New("Invalid digest. Cannot be empty")
	}

	// Check key type
	switch k.(type) {
	case *ecdsaPrivateKey:
		return csp.verifyECDSA(k.(*ecdsaPrivateKey).pub, signature, digest, opts)
	case *ecdsaPublicKey:
		return csp.verifyECDSA(*k.(*ecdsaPublicKey), signature, digest, opts)
	default:
		return csp.BCCSP.Verify(k, signature, digest, opts)
	}
}
465881
func (c *Certificate) Verify(data []byte, sig *Signature) error {
	return c.Key.Verify(data, sig)
}
527957
func (c *Ctx) Verify(sh SessionHandle, data []byte, signature []byte) error {
	e := C.Verify(c.ctx, C.CK_SESSION_HANDLE(sh), cMessage(data), C.CK_ULONG(len(data)), cMessage(signature), C.CK_ULONG(len(signature)))
	return toError(e)
}
87717
func (s *Server) ListenTCP(addr string) error {
	tcpAddr, err := net.ResolveTCPAddr("tcp", addr)
	if err != nil {
		return err
	}

	listener, err := net.ListenTCP("tcp", tcpAddr)
	if err != nil {
		return err
	}

	s.doneTcp = make(chan bool)
	s.listeners = append(s.listeners, listener)
	return nil
}
626889
func (cs *CSCloud) verifyHosts(nodes []*v1.Node) ([]string, string, error) {
	hostNames := map[string]bool{}
	for _, node := range nodes {
		hostNames[node.Name] = true
	}

	p := cs.client.VirtualMachine.NewListVirtualMachinesParams()
	p.SetListall(true)

	if cs.projectID != "" {
		p.SetProjectid(cs.projectID)
	}

	l, err := cs.client.VirtualMachine.ListVirtualMachines(p)
	if err != nil {
		return nil, "", fmt.Errorf("error retrieving list of hosts: %v", err)
	}

	var hostIDs []string
	var networkID string

	// Check if the virtual machine is in the hosts slice, then add the corresponding ID.
	for _, vm := range l.VirtualMachines {
		if hostNames[vm.Name] {
			if networkID != "" && networkID != vm.Nic[0].Networkid {
				return nil, "", fmt.Errorf("found hosts that belong to different networks")
			}

			networkID = vm.Nic[0].Networkid
			hostIDs = append(hostIDs, vm.Id)
		}
	}

	return hostIDs, networkID, nil
}