Socket Error: 90: Message Too Long

I have an error from the following script when calling an IGMP socket:

fd = socket(PF_INET,  SOCK_RAW, IPPROTO_IGMP) ;
setsockopt( fd, IPPROTO_IP, IP_HDRINCL, nval, sizeof(nval) );
/** Fill in the IP header and Ethernet header**/
/*** Fill, create the IGMP packet structures***/
if(sendto( fd, &buf, sizeof(buf), 0,(struct sockaddr *) &addr, sizeof(addr)) < 0) {
    printf("Socket Sendto error %d : %s\n", errno, strerror(errno));
    return 0;
}

the sendto call does not work if the message is too long. I use 8192 as the size of the buffer. So I tried using the following call to fix this error;

if(setsockopt(dlpifd, IPPROTO_IP, SO_SNDBUF, &val, sizeof(int)) < 0) {
   printf("Can't set socket options:%d:%s\n", errno, strerror(errno));
   return 0;`
}

calling setsockopt () succeeds, but the same error for sendto ();

So, I checked the size of SO_SNDBUF using the getsockopt () method and displayed 1 byte ?!

What is wrong, what am I doing.

Do I need to recompile the Linux kernel to support IGMP? or am I missing something?

+5
source share
1 answer

Ethernet ( , , , ), 1500 . send() , .

SO_SNDBUF , , TCP, UDP .

+7

All Articles