I'm making a UDP connection (successfully) to a device based on its IP Address and Port. I can successfully send messages to it (encoded in bytes). However, I am not seeing a response returned from the client.Receive() method.
My technical question to you is related to this Receive() method.
Perhaps my understanding is totally wrong, but I imagined that the IP Address + Port i used to connect to the device should be the same for when im calling the Receive() method.
But based on examples it seems this is not the case.
Can someone explain to me why the same IP Address + Port is not used when calling Receive()?
A) Note that i can see a response using a sniffer like Wireshark. But i just dont see the response returning from the C# udpClient.Receive(ref endpoint) method itself.
B) Also, i am using this API document which says that the device (drone) can receive and send a response on the same IPAddress + port.
UDP packets are stateless, there isn't really a connection. Unlike TCP streams, the connect method doesn't trigger any network packets. All it does is provide a default address so you don't need to provide one when sending new packets. And setup a packet filter so only packets that exactly match that remote address (including port number) will be received.
The receive method should still give you the address of the remote endpoint.
Note that if you haven't bound your UdpClient to a specific end point, and the machine has multiple network addresses, the OS may send the packet from a different address than you expect.