networking question

devendra.aaru devendra.aaru at gmail.com
Fri Mar 15 03:19:43 EDT 2013


This is my client:

#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
main()
{
        int s;
        int opt = 1;
        struct sockaddr_in serv;
        char *ip = "192.168.20.166";
        struct sockaddr_in m;

        s = socket(AF_INET, SOCK_DGRAM, 0);

        serv.sin_family = AF_INET;
        serv.sin_addr.s_addr = inet_addr("224.0.0.1");
        serv.sin_port = htons(1111);

        memset(&m, 0, sizeof(m));
        m.sin_addr.s_addr = inet_addr(ip);
        setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &m, sizeof(m));

        while (1) {
                sendto(s, ip, strlen(ip), 0, (struct sockaddr *)&serv,
sizeof(serv));
                sleep(1);
        }
}


I couldn't run a server this time but i captured packets on the other
host in tcpdump. I did get the 224.0.0.1 mcast packets,

is this something that the kernel always does registers by default to
the all node multicast in v4 and v6 case also?

or is my program buggy? thanks,

On Thu, Mar 14, 2013 at 2:11 PM, Rami Rosen <roszenrami at gmail.com> wrote:
> Hi,
>
> Can you post your client and server code?
>
> rgs,
> Rami Rosen
> http://ramirose.wix.com/ramirosen
>
>
> On Thu, Mar 14, 2013 at 12:55 PM, devendra.aaru <devendra.aaru at gmail.com> wrote:
>> Hey all,
>>
>> I have got a strange bug(?) while testing the multicasting server and client.
>>
>> I have done only the INADDR_ANY bind in server and client adds its
>> IP_MULTICAST_IF to 224.0.0.1 ,
>>
>> surprisingly i recvd pkts from the client with out joining using
>> IP_ADD_MEMBERSHIP.
>>
>> Is that a bug? or as we listening on INADDR_ANY will make us recv all
>> the mcast/bcast pkts?
>>
>> while if i do tx on 224.0.0.3 , the server is not able to recv the packets.
>>
>> any ideas?
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list