“无效论证”当发送UDP数据包时,但是哪个?
我的 C++ 应用程序将二进制数据作为 UDP 数据包发送。 sendto() 调用返回 EINVAL(无效参数),但我没有发现我传递的参数有任何问题。
我对应用程序进行了跟踪,以下是相关的系统调用:
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 33
setsockopt(33, SOL_IP, IP_RECVERR, [1], 4) = 0
fcntl(33, F_SETFD, FD_CLOEXEC) = 0
bind(33, {sa_family=AF_INET, sin_port=htons(1510), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
sendto(33, "\2055\5\0\0\0\1\0\0\0\1\20 \0t\0c\300Ny\274B\10*\206H\206\367\r\2\5\0\200\200\331'\344\272\322\362sD\277\312\300\23\240\224\212\16\20\1\0\0\22", 55, 0, {sa_family=AF_INET, sin_port=htons(1510), sin_addr=inet_addr("219.132.100.190")}, 16) = -1 EINVAL (Invalid argument)
有人看到哪个参数无效吗?
该应用程序最近已被移植为支持 IPv6,但我不知道这是否与之有关。
My C++ application is sending binary data as UDP packets. The sendto() call returns EINVAL (Invalid argument), but I don't see anything wrong with the parameters I'm passing.
I did an strace of the application and here are the revelant system calls:
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 33
setsockopt(33, SOL_IP, IP_RECVERR, [1], 4) = 0
fcntl(33, F_SETFD, FD_CLOEXEC) = 0
bind(33, {sa_family=AF_INET, sin_port=htons(1510), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
sendto(33, "\2055\5\0\0\0\1\0\0\0\1\20 \0t\0c\300Ny\274B\10*\206H\206\367\r\2\5\0\200\200\331'\344\272\322\362sD\277\312\300\23\240\224\212\16\20\1\0\0\22", 55, 0, {sa_family=AF_INET, sin_port=htons(1510), sin_addr=inet_addr("219.132.100.190")}, 16) = -1 EINVAL (Invalid argument)
Does anybody see which parameter is invalid?
The application has recently been ported to support IPv6, but I don't know if that has anything to do with it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将套接字绑定到本地地址 127.1,但您正在发送到非本地主机地址。我需要检查一下,但也许 EINVAL 意味着“您无法将 127.1 数据包发送到主机之外”。
You bound your socket to the local address 127.1, but you are sending to a non-localhost address. I need to check, but perhaps the EINVAL means "you can't send 127.1 packets off-host."