目录
问题描述:
socket sendto() 函数报错;
原因:
ssize_t nSend = sendto(socketfd, pkt_data, length , 0, (struct sockaddr*) &remote_eth_addr,sizeof(struct sockaddr*));
sendto() 函数最后一个参数错误, sizeof(struct sockaddr*)
解决:
修改为,实际传递参数remote_eth_addr 的大小,
ssize_t nSend = sendto(socketfd, pkt_data, length , 0, (struct sockaddr*) &remote_eth_addr,sizeof(remote_eth_addr))
参考:
c - Socket programming: sendto always fails with errno 22 (EINVAL) - Stack Overflow
https://stackoverflow.com/questions/4795787/socket-error90message-too-long