// refuser refuses a TCP connection
778754
func (t *TcpListener) refuser(conn *net.TCPConn) {
	// Tell the connection why we are closing.
	fmt.Fprintf(conn, "Telegraf maximum concurrent TCP connections (%d)"+
		" reached, closing.\nYou may want to increase max_tcp_connections in"+
		" the Telegraf tcp listener configuration.\n", t.MaxTCPConnections)
	conn.Close()
	log.Printf("I! Refused TCP Connection from %s", conn.RemoteAddr())
	log.Printf("I! WARNING: Maximum TCP Connections reached, you may want to" +
		" adjust max_tcp_connections")
}
264722
func (s *Socket) Accept() (net.Conn, error) {
	mu.Lock()
	defer mu.Unlock()
	for {
		syn, err := s.nextSyn()
		if err != nil {
			return nil, err
		}
		c, ok := s.ackSyn(syn)
		if ok {
			c.updateCanWrite()
			return c, nil
		}
	}
}
49630
func (s *Server) NonceRequired() bool {
	s.mu.Lock()
	defer s.mu.Unlock()
	return s.nonceRequired()
}
593082
func (conn *SocksConn) RejectReason(reason byte) error {
	if conn.socksVersion == socks4Version {
		return sendSocks4aResponseRejected(conn)
	}
	return sendSocks5ResponseRejected(conn, reason)
}
618223
func (rf Reducer) IfNot(f func(*mesos.Resource) bool) Reducer {
	if f == nil {
		return rf
	}
	return rf.If(func(r *mesos.Resource) bool {
		return !f(r)
	})
}
653622
func negatedSelector(a Selector) Selector {
	return func(n *html.Node) bool {
		if n.Type != html.ElementNode {
			return false
		}
		return !a(n)
	}
}
1127281
func (s *sdkGrpcServer) rwlockIntercepter(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error) {
	s.lock.RLock()
	defer s.lock.RUnlock()

	return handler(ctx, req)
}
587020
func (conn *SocksConn) Reject() error {
	if conn.socksVersion == socks4Version {
		return sendSocks4aResponseRejected(conn)
	}
	return sendSocks5ResponseRejected(conn, SocksRepGeneralFailure)
}
188755
func (p Listener) Accept() (net.Conn, error) {
	rawc, err := p.Listener.Accept()
	if err != nil {
		return nil, err
	}
	return newConn(rawc), nil
}
499531
func (as *AgentServer) serveTcp(listener net.Listener) {

	for {
		// Listen for an incoming connection.
		conn, err := listener.Accept()
		if err != nil {
			fmt.Println("Error accepting: ", err.Error())
			continue
		}
		// Handle connections in a new goroutine.
		go func() {
			defer conn.Close()
			if err = conn.SetDeadline(time.Time{}); err != nil {
				fmt.Printf("Failed to set timeout: %v\n", err)
			}
			if c, ok := conn.(*net.TCPConn); ok {
				c.SetKeepAlive(true)
			}
			as.handleRequest(conn)
		}()
	}
}
952668
func TCPListener(addr string) (Listener, error) {
	laddr, err := net.ResolveTCPAddr("tcp", addr)
	if err != nil {
		return nil, err
	}
	ln, err := net.ListenTCP("tcp", laddr)
	if err != nil {
		return nil, err
	}
	return &tcpListener{Listener: tcpKeepAliveListener{ln}}, nil
}
969754
func (p *Listener) Accept() (net.Conn, error) {
	// Get the underlying connection
	conn, err := p.Listener.Accept()
	if err != nil {
		return nil, err
	}
	var useConnAddr bool
	if p.SourceCheck != nil {
		allowed, err := p.SourceCheck(conn.RemoteAddr())
		if err != nil {
			return nil, err
		}
		if !allowed {
			useConnAddr = true
		}
	}
	newConn := NewConn(conn, p.ProxyHeaderTimeout)
	newConn.useConnAddr = useConnAddr
	return newConn, nil
}
1230263
func (r *req) resender() {

	defer r.w.Done()
	cq := r.sock.CloseChannel()

	for {
		select {
		case <-r.waker.C:
		case <-cq:
			return
		}

		r.Lock()
		m := r.reqmsg
		if m == nil {
			r.Unlock()
			continue
		}
		m = m.Dup()
		r.Unlock()

		r.resend <- m
		r.Lock()
		if r.retry > 0 {
			r.waker.Reset(r.retry)
		} else {
			r.waker.Stop()
		}
		r.Unlock()
	}
}
1298187
func UserAgentUnaryServerInterceptor(clientName, constraintStr string) grpc.UnaryServerInterceptor {
	userAgentEnforcer := newUserAgentEnforcer(clientName, constraintStr)
	return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
		if err := userAgentEnforcer(ctx); err != nil {
			return nil, err
		}
		return handler(ctx, req)
	}
}
303034
func IPNetOr(n1, n2 *net.IPNet) *net.IPNet {
	oip := SliceOr(n1.IP, n2.IP)
	omask := SliceOr(n1.Mask, n2.Mask)
	return &net.IPNet{IP: oip, Mask: omask}
}
927669
func (g *srvGateway) rejectUnknown() bool {
	g.RLock()
	reject := g.runknown
	g.RUnlock()
	return reject
}
164088
func (ln TCPKeepAliveListener) Accept() (c net.Conn, err error) {
	for {
		ln.SetDeadline(time.Now().Add(time.Second))
		select {
		case <-ln.cancel:
			return nil, errors.New("port closed")
		default:
		}

		conn, err := ln.AcceptTCP()
		if err != nil {
			switch err := err.(type) {
			case net.Error:
				if err.Timeout() {
					continue
				}
			}
			return nil, err
		}
		conn.SetKeepAlive(true)
		conn.SetKeepAlivePeriod(3 * time.Minute)

		// and return the connection.
		return conn, nil
	}
}