listener.go
func (l *DefaultListener) listenRoutine() {
	for {
		conn, err := l.listener.Accept()

		if !l.IsRunning() {
			break // Go to cleanup
		}

		// listener wasn't stopped,
		// yet we encountered an error.
		if err != nil {
			PanicCrisis(err)
		}

		l.connections <- conn
	}

	// Cleanup
	close(l.connections)
	for _ = range l.connections {
		// Drain
	}
}
func (l *DefaultListener) listenRoutine() {
	for {
		conn, err := l.listener.Accept()

		if !l.IsRunning() {
			break // Go to cleanup
		}

		// listener wasn't stopped,
		// yet we encountered an error.
		if err != nil {
			PanicCrisis(err)
		}

		l.connections <- conn
	}

	// Cleanup
	close(l.connections)
	for _ = range l.connections {
		// Drain
	}
}
func ( l * DefaultListener ) listenRoutine ( ) { for { conn , err := l . listener . Accept ( ) if ! l . IsRunning ( ) { break // Go to cleanup } // listener wasn't stopped, // yet we encountered an error. if err != nil { PanicCrisis ( err ) } l . connections <- conn } // Cleanup close ( l . connections ) for _ = range l . connections { // Drain } }
// Accept connections and pass on the channel
Accept connections and pass on the channel