Using the same port for 2 UDP Multicast groups
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Using the same port for 2 UDP Multicast groups

  1. #1
    Join Date
    Sep 2013
    Posts
    13

    Using the same port for 2 UDP Multicast groups

    I habe a program, that can send and receive UDP Multicast telegrams. When I open the socket then I bind my multicast group address and the local port to a specified networkcard (our PC has 2 network cards). Now I have a special constellation:

    Our PC has 2 network cards. Multicast group 1 shall use card 1 and group shall use card 2. As long as both groups use different local ports it works fine. But when both group want to use the same port number then I can receive and send telegrams only through the first group that was created. For the second one I don't even get a FD_READ event at all.

    Code:
           SrvAddr.sin_family         = AF_INET;
           SrvAddr.sin_port           = htons( (WORD) nLocalPort );
           
           SrvAddr.sin_addr.s_addr    = inet_addr(strOwnIpAddress); // bind multicast group socket to a specified networkcard
           
           // If bind socket to port failed
           if( bind( hSocket,
                          (const struct sockaddr *) &SrvAddr,
                          sizeof(SrvAddr) )               == SOCKET_ERROR )
           {
                 WSACloseEvent(ptChannel->Overlapped.hEvent);
                 closesocket(hSocket);
                 WSACleanup();
                 return ceUdpErrBind;
           }  // END OF If bind socket to port failed

  2. #2
    Join Date
    Sep 2013
    Posts
    13

    Re: Using the same port for 2 UDP Multicast groups

    I found my mistake. Problem is solved

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Using the same port for 2 UDP Multicast groups

    Quote Originally Posted by grka View Post
    I found my mistake. Problem is solved
    Will you be so kind to share your solution?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center