2016-05-17 06:26 阅读 57

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

This link has information about OOB in TCP.

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.

But what about UDP?

In golang, the ReadMsgUDP function requires an oob byte slice.

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

What is the oob for? Are there any use cases in open source code? Or should I use PacketConn instead of UDPConn?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dqtm8504 dqtm8504 2016-06-29 06:29

    Well, as I tried, when you want other infomation(such as pktinfo) to get local address with setting syscall.setsockoption, you will need it. This happens when you don't want connection-oriented UDP.

    点赞 评论 复制链接分享