Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Locked UDP listening IP not port

  • Monday, May 07, 2012 7:20 AM
     
     

    (sorry for my english)

    Hi. I have a problem with the reception data. I want the server to receive data onlyfrom certain IP addresses, but to me it does not work. What is wrong? Here is my server code:

        string stipaddress = "127.0.0.1";
                IPAddress ipAddress = IPAddress.Parse(stipaddress);
                UdpClient recivingudpClient = new UdpClient(stipaddress, 5006);
                
                IPEndPoint RmoteIPEnd = new IPEndPoint(ipAddress,5006);
                try
                {
                    byte[] reciverBytes = recivingudpClient.Receive(ref RmoteIPEnd);
                    MemoryStream ms = new MemoryStream(reciverBytes);
                    pictureBox1.Image = Image.FromStream(ms);
                    recivingudpClient.Close();
         
                }
                catch (Exception ex)
                {
                   
                    MessageBox.Show(ex.ToString());
                }




All Replies

  • Monday, May 07, 2012 7:59 AM
     
     Answered
    Please read the documentation for UdpClient.Receive() carefully. If you intend to specify you only want to receive from certain host, you need to call Connect() before Receive()
    • Marked As Answer by Eddie_Kennedy Monday, May 07, 2012 1:41 PM
    •  
  • Monday, May 07, 2012 11:20 AM
     
     Answered

    What UDP recieve protocol does is allows a user to register to recieve all messages on a specific port number.  You are using the 127.0.0.1 (loopback address) on you PC as the interface to recieve messages.  UDP client interface doesn't provide any filtering for you to accept or deny the source address.  You have to add your own filtering to accept messagge from certain locations/devices.

    I have an application where I'm recieving messages from specific manufactures device and to make sure I'm only getting messages from these devices I check the MAC Address (physical address) of the device.  the MAC address is 6 hex bytes with the first few bytes being a manufauctures ID and the last set of bytes are the different part numberr each manufactures produces.  If you type in a DOS window ARP -A you will  see some MAC address.  The ARP table gets filled when you send a PING to a device, or when a computer is turned on it will send out an ARP message to let other computers in the network know the computer IP address.   The ARP table entries time out after a period of time (around 30 minutes).

    MAC address format : XX-XX-XX-XX-XX-XX


    jdweng

    • Marked As Answer by Eddie_Kennedy Monday, May 07, 2012 1:41 PM
    •  
  • Monday, May 07, 2012 2:07 PM
     
     

    What UDP recieve protocol does is allows a user to register to recieve all messages on a specific port number.  You are using the 127.0.0.1 (loopback address) on you PC as the interface to recieve messages.  UDP client interface doesn't provide any filtering for you to accept or deny the source address.  You have to add your own filtering to accept messagge from certain locations/devices.

    I have an application where I'm recieving messages from specific manufactures device and to make sure I'm only getting messages from these devices I check the MAC Address (physical address) of the device.  the MAC address is 6 hex bytes with the first few bytes being a manufauctures ID and the last set of bytes are the different part numberr each manufactures produces.  If you type in a DOS window ARP -A you will  see some MAC address.  The ARP table gets filled when you send a PING to a device, or when a computer is turned on it will send out an ARP message to let other computers in the network know the computer IP address.   The ARP table entries time out after a period of time (around 30 minutes).

    MAC address format : XX-XX-XX-XX-XX-XX


    jdweng

    can you show me how you check MAC?
  • Tuesday, May 08, 2012 1:03 AM
     
     

    > If you type in a DOS window ARP -A you will  see some MAC address.

    It's already posted there, I think. I'll add that you can run "ipconfig /all" to show your MAC address per your network adapters (as "Physical Address").


    • Edited by cheong00 Tuesday, May 08, 2012 1:03 AM
    •