Determine Local IP of UDP client data packet

Roger Alcindor
Roger Alcindor used Ask the Experts™
I am using an Indy 10 UDP client component with Embarcadero C++ builder EX 10.1 Berlin

I need to determine the IP address of the local PC that received the broadcast packet (not the peer IP). there are two network cards.
The UDP client is bound to port 13580

How do I determine the IP address of the Ethernet port that generated the event ?

void __fastcall TForm1::IdSystatUDPServer1UDPRead(TIdUDPListenerThread *AThread, const TIdBytes AData,
          TIdSocketHandle *ABinding)
	UnicodeString u;

	u = ABinding->IP; // this is the binding which is
 	u = AThread->Binding->IP; // I was expecting this to give what I want but it returns .

	if(u == u"")  // only use specified local ethernet port
{ // handle differently if another network adapter received the data


Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Geert GOracle dba
Top Expert 2009

we fill a database table with the ip adress, port and exe name at startup
and gets reset every x hours

an automated job, deletes entries older then x+1 hours

here is a link on how to get the local ip with several methods

some require admin rights


Thanks for your comment, interesting and informative though it is, it doesn't answer my question. I already know the IP addresses of the local machine.
What I need to know is which one received the UDP packet that triggered the Indy IdSystatUDPServer1UDPRead event handler as shown in my code sample.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial