您的位置:首页 > 运维架构 > Linux

UDP通信recvfrom返回invalid argument

2016-12-09 19:54 323 查看
//原文地址:http://blog.chinaunix.net/uid-26497520-id-3891017.html

这个问题很可能出在addrlen参数上,以下是man文档的解释

If src_addr is not NULL, and the underlying protocol provides the

source address, this source address is filled in. When src_addr is

NULL, nothing is filled in; in this case, addrlen is not used, and

should also be NULL. The argument addrlen is a value-result argument,

which the caller should initialize before the call to the size of the

buffer associated with src_addr, and modified on return to indicate the

actual size of the source address. The returned address is truncated

if the buffer provided is too small; in this case, addrlen will return

a value greater than was supplied to the call.

自注: 大冬天的在工厂调试,遇到这种问题也是醉了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux socket udp