func (l *listener) readLoop() {
	defer l.readWG.Done()
	for {
		buf := *(readBufferPool.Get().(*[]byte))
		n, raddr, err := l.pConn.ReadFrom(buf)
		if err != nil {
			return
		}
		conn, ok, err := l.getConn(raddr, buf[:n])
		if err != nil {
			continue
		}
		if ok {
			_, _ = conn.buffer.Write(buf[:n])
		}
	}
}
readLoop has to tasks:
1. Dispatching incoming packets to the correct Conn.
It can therefore not be ended until all Conns are closed.
2. Creating a new Conn when receiving from a new remote.
package udp
import (
	"context"
	"errors"
	"net"
	"sync"
	"sync/atomic"
	"time"
	"github.com/pion/transport/deadline"
	"github.com/pion/transport/packetio"
)
const receiveMTU = 8192
const defaultListenBacklog = 128  
var errClosedListener = errors.New("udp: listener closed")
var errListenQueueExceeded = errors.New("udp: listen queue exceeded")
type listener struct {
	pConn *net.UDPConn
	accepting    atomic.Value  
	acceptCh     chan *Conn
	doneCh       chan struct{}
	doneOnce     sync.Once
	acceptFilter func([]byte) bool
	connLock sync.Mutex
	conns    map[string]*Conn
	connWG   sync.WaitGroup
	readWG   sync.WaitGroup
	errClose atomic.Value  
}
func (l *listener) Accept() (net.Conn, error) {
	select {
	case c := <-l.acceptCh:
		l.connWG.Add(1)
		return c, nil
	case <-l.doneCh:
		return nil, errClosedListener
	}
}
func (l *listener) Close() error {
	var err error
	l.doneOnce.Do(func() {
		l.accepting.Store(false)
		close(l.doneCh)
		l.connLock.Lock()
	L_CLOSE:
		for {
			select {
			case c := <-l.acceptCh:
				close(c.doneCh)
				delete(l.conns, c.rAddr.String())
			default:
				break L_CLOSE
			}
		}
		nConns := len(l.conns)
		l.connLock.Unlock()
		l.connWG.Done()
		if nConns == 0 {
			l.readWG.Wait()
			if errClose, ok := l.errClose.Load().(error); ok {
				err = errClose
			}
		} else {
			err = nil
		}
	})
	return err
}
func (l *listener) Addr() net.Addr {
	return l.pConn.LocalAddr()
}
type ListenConfig struct {
	Backlog int
	AcceptFilter func([]byte) bool
}
func (lc *ListenConfig) Listen(network string, laddr *net.UDPAddr) (net.Listener, error) {
	if lc.Backlog == 0 {
		lc.Backlog = defaultListenBacklog
	}
	conn, err := net.ListenUDP(network, laddr)
	if err != nil {
		return nil, err
	}
	l := &listener{
		pConn:        conn,
		acceptCh:     make(chan *Conn, lc.Backlog),
		conns:        make(map[string]*Conn),
		doneCh:       make(chan struct{}),
		acceptFilter: lc.AcceptFilter,
	}
	l.accepting.Store(true)
	l.connWG.Add(1)
	l.readWG.Add(2)  
	go l.readLoop()
	go func() {
		l.connWG.Wait()
		if err := l.pConn.Close(); err != nil {
			l.errClose.Store(err)
		}
		l.readWG.Done()
	}()
	return l, nil
}
func Listen(network string, laddr *net.UDPAddr) (net.Listener, error) {
	return (&ListenConfig{}).Listen(network, laddr)
}
var readBufferPool = &sync.Pool{
	New: func() interface{} {
		buf := make([]byte, receiveMTU)
		return &buf
	},
}