[help need] IPv6 multicast in winsock2?

This is a discussion on [help need] IPv6 multicast in winsock2? within the Networking/Device Communication forums, part of the General Programming Boards category; I'm writing a simple piece of code to let the client to be able to receive multicast UDPs to link-local ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    6

    [help need] IPv6 multicast in winsock2?

    I'm writing a simple piece of code to let the client to be able to receive multicast UDPs to link-local all-node "ff02::1". But I encountered the following problem. Any comments?

    I'm under Windows XP SP2. According to msdn IPPROTO_IPV6 page, it should be
    supported by this OS. But the "setsockopt" line of code gives 10022(WSAEINVAL: The level parameter is not valid, or the information in optval parameter is not valid.)

    IPV6_MREQ imr;
    TCHAR *all_nodes = L"ff02::1";
    //get IPv6 multicast address from string
    if ( WSAStringToAddress(all_nodes, AF_INET6, NULL, (struct sockaddr *)&sin, &len) == SOCKET_ERROR)
    {
    ...... //break out
    }

    //set option to join link-local all-nodes multicast group
    imr.ipv6mr_interface = 0;
    imr.ipv6mr_multiaddr = sin.sin6_addr; //all_nodes;

    if (::setsockopt(m_sockBCastV6, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&imr, sizeof(imr)) == SOCKET_ERROR)
    {
    ...... //break out
    }

    I also tried other options at IPPROTO_IPV6, and the only option that didn't
    give 10022 error is IPV6_MULTICAST_IF.

    I'm using Visual C++ in Visual Studio 2005. And OS is Windows XP, SP2.

    Any help would be highly appreciated!

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I'm not sure what the problem is (your code looks alright, have you made sure that you have IPv6 installed?) but you may wish to take a look at the IPv6 multicast example code thread.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    6

    problem solved

    I don't know why it should work like this. But switching the order of setsockopt and bind solves the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IPv6 multicast client fails to receive server response
    By perfect in forum Networking/Device Communication
    Replies: 10
    Last Post: 06-21-2009, 11:30 PM
  2. IPv6 multicast example code
    By Sang-drax in forum Networking/Device Communication
    Replies: 7
    Last Post: 07-25-2005, 09:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21