func (*UDPConn) ReadMsgUDP 中的 oob 是什么?

What is oob in func (*UDPConn) ReadMsgUDP?

This link 有关于 TCP 中 OOB 的信息。

With out-of-band data we want the byte-stream service layer on the sending side to send this data before any other data that it has buffered. Similarly we want the receiving end to pass this data to its user process ahead of any data that it might have buffered.

但是 UDP 呢?

在 golang 中,ReadMsgUDP 函数需要一个 oob 字节切片。

func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error)

oob 有什么用?开源代码中是否有任何用例?或者我应该使用 PacketConn 而不是 UDPConn

好吧,正如我所尝试的,当您希望其他信息(例如 pktinfo)通过设置 syscall.setsockoption 获取本地地址时,您将需要它。当您不想要面向连接的 UDP 时,就会发生这种情况。