从CMSG获取时间戳记可能为null吗?
This code try to print the timestamp of packet using struct timespec *stamp =(struct timespec *)cmsg_data(cmsg);
如果是UDP数据包。
有什么办法 CMSG_DATA(CMSG)
将返回null?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看您看到
这将偏移添加到
cmsg
。除非您设法将
cmsg
馈入该宏,否则添加该偏移量后,该宏将评估为null
,则结果永远无法null
。If you look at the definition of CMSG_DATA you see
This adds an offset to
cmsg
.Unless you manage to feed a
cmsg
into that macro that evaluates toNULL
after adding that offset, the result can never be comeNULL
.