func (s *Server) Close() error {
	if !s.running.Load().(bool) {
		return nil
	}
	s.running.Store(false)
	err := s.listener.Close()

	// close all active connections discarding any read/writes that is going on currently
	s.conns.Range(func(c interface{}) {
		c.(*Conn).Close()
	})

	if err != nil {
		return fmt.Errorf("an error occured before or while stopping the server: %v", err)
	}

	s.wg.Wait()
	log.Printf("server: stopped %v", s.addr)
	return nil
}
func (s *Server) Close() error {
	if !s.running.Load().(bool) {
		return nil
	}
	s.running.Store(false)
	err := s.listener.Close()

	
	s.conns.Range(func(c interface{}) {
		c.(*Conn).Close()
	})

	if err != nil {
		return fmt.Errorf("an error occured before or while stopping the server: %v", err)
	}

	s.wg.Wait()
	log.Printf("server: stopped %v", s.addr)
	return nil
}
func ( s * Server ) Close ( ) error { if ! s . running . Load ( ) . ( bool ) { return nil } s . running . Store ( false ) err := s . listener . Close ( ) // close all active connections discarding any read/writes that is going on currently s . conns . Range ( func ( c interface { } ) { c . ( * Conn ) . Close ( ) } ) if err != nil { return fmt . Errorf ( " " , err ) } s . wg . Wait ( ) log . Printf ( " " , s . addr ) return nil }
// Close closes the network listener and the active connections.
Close closes the network listener and the active connections .