// ListenAndServe listens on the TCP network address s.Addr and then
// calls Serve to handle requests on incoming connections.  If
// s.Addr is blank, ":389" is used.
347091
func (s *Server) ListenAndServe(addr string, options ...func(*Server)) error {

	if addr == "" {
		addr = ":389"
	}

	var e error
	s.Listener, e = net.Listen("tcp", addr)
	if e != nil {
		return e
	}
	Logger.Printf("Listening on %s\n", addr)

	for _, option := range options {
		option(s)
	}

	return s.serve()
}
1176796
func (s *Server) listenAndServe(addr string, handler http.Handler, context hap.Context) error {
	server := http.Server{Addr: addr, Handler: handler}
	// Use a TCPListener
	listener := hap.NewTCPListener(s.listener, context)
	s.hapListener = listener
	return server.Serve(listener)
}
890043
func (service *Service) ListenAndServe(addr string) error {
	service.LogInfo("listen", "transport", "http", "addr", addr)
	service.Server.Addr = addr
	return service.Server.ListenAndServe()
}
1021503
func (a *Agent) ListenAndServe(ctx context.Context) error {
	out.Debug(ctx, "Trying to listen on %s", a.socket)
	lis, err := net.Listen("unix", a.socket)
	if err == nil {
		return a.server.Serve(lis)
	}

	out.Debug(ctx, "Failed to listen on %s: %s", a.socket, err)
	if err := client.New(filepath.Dir(a.socket)).Ping(ctx); err == nil {
		return fmt.Errorf("agent already running")
	}
	if err := os.Remove(a.socket); err != nil {
		return errors.Wrapf(err, "failed to remove old agent socket %s: %s", a.socket, err)
	}
	out.Debug(ctx, "Trying to listen on %s after removing old socket", a.socket)
	lis, err = net.Listen("unix", a.socket)
	if err != nil {
		return errors.Wrapf(err, "failed to listen on %s after cleanup: %s", a.socket, err)
	}
	return a.server.Serve(lis)
}
683817
func (s *Server) ListenAndServeTLS(certFile, keyFile string) error {
	if len(certFile) == 0 || len(keyFile) == 0 {
		panic("either CertFile/KeyFile must be blank, or both provided")
	}
	s.KeyFile = keyFile
	s.CertFile = certFile
	return s.ListenAndServe()
}
632474
func (kl *Kubelet) ListenAndServe(address net.IP, port uint, tlsOptions *server.TLSOptions, auth server.AuthInterface, enableDebuggingHandlers, enableContentionProfiling bool) {
	server.ListenAndServeKubeletServer(kl, kl.resourceAnalyzer, address, port, tlsOptions, auth, enableDebuggingHandlers, enableContentionProfiling, kl.redirectContainerStreaming, kl.criHandler)
}
612797
func ListenAndServe(addr string, handler http.Handler, logger *zap.Logger) error {
	l, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	server := NewServer(handler, logger)
	server.ListenForSignals(os.Interrupt, syscall.SIGTERM)
	return server.Serve(l)
}
126853
func (pn *peernet) ListenAddresses() []ma.Multiaddr {
	return pn.Peerstore().Addrs(pn.LocalPeer())
}
825665
func Listen(address string, tr *Transport) (*Listener, error) {
	var err error
	l := &Listener{Transport: tr}
	config, err := tr.getConfig()
	if err != nil {
		return nil, err
	}

	l.Listener, err = tls.Listen("tcp", address, config)
	return l, err
}
407032
func (s *Server) ListenAndServe() error {
	addr := s.Addr
	if addr == "" {
		addr = ":imap"
	}

	l, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}

	return s.Serve(l)
}
730640
func (srv *Server) ListenAndServeTLSConfig(config *tls.Config) error {
	addr := srv.Addr
	if addr == "" {
		addr = ":https"
	}

	conn, err := srv.newTCPListener(addr)
	if err != nil {
		return err
	}

	srv.TLSConfig = config

	tlsListener := tls.NewListener(conn, config)
	return srv.Serve(tlsListener)
}
445387
func (p *Proxy) ListenAndServe() error {
	var err error
	p.listener, err = net.Listen("tcp4",
		net.JoinHostPort(p.Kite.Config.IP, strconv.Itoa(p.Kite.Config.Port)))
	if err != nil {
		return err
	}
	p.Kite.Log.Info("Listening on: %s", p.listener.Addr().String())

	close(p.readyC)

	server := http.Server{
		Handler: p.mux,
	}

	defer close(p.closeC)
	return server.Serve(p.listener)
}
269945
func (m *ServeMux) ListenAndServe(addr string) error {
	m.Prepare()

	server := &http.Server{Addr: addr, Handler: m}
	return server.ListenAndServe()
}
280448
func ListenAndServeIfUnicast(interfaceName string, handler Handler, jobs chan job, ip net.IP, ctx context.Context) error {
	iface, err := net.InterfaceByName(interfaceName)
	if err != nil {
		return err
	}

	p, err := UnicastOpen(ip, 67, interfaceName)
	if err != nil {
		return err
	}
	defer p.Close()

	return ServeIf(iface.Index, p, handler, jobs, ctx)
}
201593
func (a *TCPAcceptor) ListenAndServeTLS(cert, key string) {
	crt, err := tls.LoadX509KeyPair(cert, key)
	if err != nil {
		logger.Log.Fatalf("Failed to listen: %s", err.Error())
	}

	tlsCfg := &tls.Config{Certificates: []tls.Certificate{crt}}

	listener, err := tls.Listen("tcp", a.addr, tlsCfg)
	a.listener = listener
	a.running = true
	a.serve()
}
194538
func (m *Mux) ListenAndServe(port string) error {
	return http.ListenAndServe(port, m)
}
454591
func (s *Server) ListenAndServe(addr string) error {
	a, err := net.ResolveUDPAddr("udp", addr)
	if err != nil {
		return err
	}
	conn, err := net.ListenUDP("udp", a)
	if err != nil {
		return err
	}
	return s.Serve(conn)
}