func()

in connection.go [420:441]


func (u *gettyUDPConn) recv(p []byte) (int, *net.UDPAddr, error) {
	if u.rTimeout.Load() > 0 {
		// Optimization: update read deadline only if more than 25%
		// of the last read deadline exceeded.
		// See https://github.com/golang/go/issues/15133 for details.
		currentTime := time.Now()
		if currentTime.Sub(u.rLastDeadline.Load()) > u.rTimeout.Load()>>2 {
			if err := u.conn.SetReadDeadline(currentTime.Add(u.rTimeout.Load())); err != nil {
				return 0, nil, perrors.WithStack(err)
			}
			u.rLastDeadline.Store(currentTime)
		}
	}

	length, addr, err := u.conn.ReadFromUDP(p) // connected udp also can get return @addr
	log.Debugf("ReadFromUDP(p:%d) = {length:%d, peerAddr:%s, error:%v}", len(p), length, addr, err)
	if err == nil {
		u.readBytes.Add(uint32(length))
	}

	return length, addr, perrors.WithStack(err)
}