// Listen implements caddy.TCPServer interface.
336935
func (s *ServerTLS) Listen() (net.Listener, error) {
	l, err := net.Listen("tcp", s.Addr[len(transport.TLS+"://"):])
	if err != nil {
		return nil, err
	}
	return l, nil
}
519066
func (c *Collector) Listen(port int) error {
	var err error
	c.ln, err = net.Listen("tcp", ":"+strconv.Itoa(port))
	return err
}
1337881
func Listen(addr string, c chan Packet) {
	laddr, err := net.ResolveUDPAddr("udp", addr)
	if err != nil {
		log.Fatalln("fatal: failed to resolve address", err)
	}
	conn, err := net.ListenUDP("udp", laddr)
	if err != nil {
		log.Fatalln("fatal: failed to listen", err)
	}
	for {
		buf := make([]byte, 1452)
		n, err := conn.Read(buf[:])
		if err != nil {
			log.Println("error: Failed to recieve packet", err)
		} else {
			packets, err := Parse(buf[0:n])
			if err != nil {
				log.Println("error: Failed to recieve packet", err)
			}
			for _, p := range *packets {
				c <- p
			}
		}
	}
}
134081
func Listen(proto, addr string) (l net.Listener, err error) {
	return NewReusablePortListener(proto, addr)
}
174635
func (z *Zipkin) Listen(ln net.Listener, acc telegraf.Accumulator) {
	if err := z.server.Serve(ln); err != nil {
		// Because of the clean shutdown in `(*Zipkin).Stop()`
		// We're expecting a server closed error at some point
		// So we don't want to display it as an error.
		// This interferes with telegraf's internal data collection,
		// by making it appear as if a serious error occurred.
		if err != http.ErrServerClosed {
			acc.AddError(fmt.Errorf("E! Error listening: %v", err))
		}
	}
}
114477
func (service *TCPService) Serve(listener net.Listener) {
	service.ServeTCP(listener.(*net.TCPListener))
}
768207
func (p *Progress) Listen() {
	for {

		p.mtx.Lock()
		interval := p.RefreshInterval
		p.mtx.Unlock()

		select {
		case <-time.After(interval):
			p.print()
		case <-p.tdone:
			p.print()
			close(p.tdone)
			return
		}
	}
}
398844
func (c *Client) Listen(n, addr string) (net.Listener, error) {
	laddr, err := net.ResolveTCPAddr(n, addr)
	if err != nil {
		return nil, err
	}
	return c.ListenTCP(laddr)
}
378205
func (s *Strobe) Listen() ClosableReceiver {
	l := listener{channel: make(chan string), closer: make(chan struct{})}
	s.lock.Lock()
	defer s.lock.Unlock()
	s.listeners[l] = struct{}{}
	go s.waitForClose(l)
	return &l
}
1022807
func (s *SQS) Listen(fn dispatch.Listenner) error {

	errChan := make(chan error)

	go func() {

		for true {
			params := &sqs.ReceiveMessageInput{
				QueueUrl:            s.queueURL,
				MaxNumberOfMessages: aws.Int64(1),
			}

			if resp, err := s.client().ReceiveMessage(params); err != nil {
				errChan <- err
				break

			} else {
				for _, m := range resp.Messages {

					if m.Body != nil {
						if decoded, err := base64.StdEncoding.DecodeString(*m.Body); err != nil {
							errChan <- err
							return

						} else if err := fn(decoded); err != nil {
							errChan <- err
							return

						} else if err := s.ack(m); err != nil {
							errChan <- err
							return

						}
					}
				}
			}
		}
	}()

	return <-errChan

}
1007975
func Listen(network, laddr string) (Listener, error) {
	tcpaddr, err := net.ResolveTCPAddr(network, laddr)
	if err != nil {
		return nil, err
	}

	ln, err := net.ListenTCP(network, tcpaddr)
	if err != nil {
		return nil, err
	}

	return &listener{ln}, err
}
950645
func (a *TCPAcceptor) ListenAndServe() {
	if a.hasTLSCertificates() {
		a.ListenAndServeTLS(a.certFile, a.keyFile)
		return
	}

	listener, err := net.Listen("tcp", a.addr)
	if err != nil {
		logger.Log.Fatalf("Failed to listen: %s", err.Error())
	}
	a.listener = listener
	a.running = true
	a.serve()
}
471354
func (s *SSHServer) listen(c context.Context) {
	defer s.listener.Close()

	for {
		// Accepts will only block for 1s
		s.listener.SetDeadline(time.Now().Add(s.config.Deadline))

		select {

		// Stop server on channel receive
		case <-c.Done():
			s.config.Logger.Debug("Context Completed")
			return
		default:

			// Accept new connection
			tcpConn, err := s.listener.Accept()
			if err != nil {
				if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
					s.config.Logger.Debug("Connection timeout...")
				} else {
					s.config.Logger.Warn("Connection failed", "error", err)
				}
				continue
			}

			// Handle connection
			s.config.Logger.Info("Successful TCP connection:", tcpConn.RemoteAddr().String())
			s.reaper.Spawn(&tcpHandler{
				logger:         s.config.Logger,
				conn:           tcpConn,
				config:         s.config.sshConfig,
				dispatcher:     s.config.Dispatcher,
				requestHandler: s.config.Consumer,
			})
		}
	}
}
788647
func (b *Bot) Listen() {
	var msg Message

	for {
		if websocket.JSON.Receive(b.Socket, &msg) == nil {
			go b.process(msg)

			// Clean up message after processign it
			msg = Message{}
		}
	}
}
677714
func (s *ServergRPC) Listen() (net.Listener, error) {

	l, err := net.Listen("tcp", s.Addr[len(transport.GRPC+"://"):])
	if err != nil {
		return nil, err
	}
	return l, nil
}
805374
func (queue *AMQP) Listen(fn dispatch.Listenner) error {
	conn, err := amqp.Dial(queue.host)
	if err != nil {
		return err
	}
	defer conn.Close()

	ch, err := conn.Channel()
	if err != nil {
		return err
	}
	defer ch.Close()

	err = ch.Qos(
		1,     // prefetch count
		0,     // prefetch size
		false, // global
	)
	if err != nil {
		return err
	}

	msgs, err := ch.Consume(
		queue.Name, // queue
		"",         // consumer
		false,      // auto-ack
		false,      // exclusive
		false,      // no-local
		false,      // no-wait
		nil,        // args
	)
	if err != nil {
		return err
	}
	errChan := make(chan error)

	go func() {
		for d := range msgs {
			if err := fn(d.Body); err != nil {
				defer d.Reject(true)
				errChan <- err
				return
			}
			d.Ack(false)
		}
	}()

	return <-errChan
}
719946
func (s *Server) Listen() {
	// Should only ever be called once
	if !s.listening {
		s.listening = true
		go s.listen()
		log.Println("weblog server running")
	}
}