UDP multicast using winsock API differences between XP and Vista

后端 未结 3 927
Happy的楠姐
Happy的楠姐 2021-02-10 04:59

It seems to be that the implementation required to set up a UDP multicast socket has changed between windows XP and windows vista. Specifically:

  • Under windows X

3条回答
  •  长发绾君心
    2021-02-10 05:30

    What error are you getting from the setsockopt() call that you make to apply IP_ADD_MEMBERSHIP and join the multicast group?

    I've just run some tests here with my server framework and I note that I DO call bind() on Windows 7 (I don't have a Vista box to hand) and I can then also join a multicast group as expected as long as both the binding address and the multicast address are valid.

    However I cannot call bind() with INADDR_ANY, as that causes the joining of the multicast group to fail with error 10022 (WSAEINVAL) and if the multicast group address isn't a valid multicast address the call fails with error 10049 (WSAEADDRNOTAVAIL). Which all seems fair enough.

    I'm booting an XP box now...

    [Edited after testing on XP]

    On XP it's legal to bind() to INADDR_ANY and it's legal to use invalid multicast addresses. So, I expect, you're doing one of those and it therefore works on XP and not on Vista/Win7.

    So, what error are you getting and what address are you binding to?

提交回复
热议问题