Search code examples
c#udpudpclientmultihomed

Problem Trying to unicast packets to available networks


Trying to unicast packets to available networks. There are totally 3 networks. Managed to get packets in only one network.But i am not able to receive the packets in different networks.

using this code..

        foreach (var i in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
        {
            foreach (var ua in i.GetIPProperties().UnicastAddresses)
            {
                System.Windows.Forms.MessageBox.Show(ua.Address.ToString());
                IPAddress Tip = IPAddress.Parse(ua.Address.ToString());
                IPEndPoint targetEndPoint = new IPEndPoint(Tip, iTargetPort);
                MyUdpClient sendUdpClient = new MyUdpClient();
                int numBytesSent = sendUdpClient.Send(CombineHeaderBody, CombineHeaderBody.Length, targetEndPoint);
            }
        }

What is the prob ? Thanks.


Solution

  • I think that you're trying to send packets to yourself?

    Are you sure you're not confusing unicast and multicast addresses?

    Ok so you're not trying to multicast...

    Each of your network interface has an ip address. What you're doing here is sending a packet to your network card. It is not really a matter of network because your machine most probably knows its own ip addresses and reroute it to 127.0.0.1