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());
}
- Edited by Eddie_Kennedy Monday, May 07, 2012 7:35 AM
All Replies
-
Monday, May 07, 2012 7:59 AM
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
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
can you show me how you check MAC?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
-
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

