Search code examples
delphi-xe3indy10

Indy TIdUDPServer component OnUDPRead - Remote IP?


Ok, this might sound stupid and pretty obvious, but I just can't get through it nor find any useful info on the web (I most likely don't know the right words to search with...)

But..

Is there a way to get the Remote IP on action ServerUDPRead on TIdUDPServer component? I'm sending packets from the server to the same port of two different machines, so to 2 IPs, and get replies to the same server component from both of them; Now the issue is how to identify where each reply came from; Is there a way to read this from the packet itself, or would I need to implement the second TIdUDPServer component instead, and send packets to each of the destination machines separately..? (Note: the machine replies back to my app to the same port where the packet was sent from. So, binded port is the one that needs to be read);

Cheers

M.


Solution

  • The OnUDPRead event handler has an ABinding parameter. The sender's IP is in the ABinding.PeerIP property.