Where can i read the IP-address of sender ? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Bas · 2021-01-31 14:18 Hello, i'm sending a broadcast message on the network to detect if there are interface boards available on the network. They then will reply with their mac address. How can i read the ip address of the unit where the message came from ? I'm using the lnet package for network communication. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TForm1.udp_1_receive(aSocket: TLSocket); Var  DataString : String; begin    UDP_1.GetMessage(DataString);    Label2.Caption:=DataString;    IpAddress = UDP_1.Something  ??????end; ---------------------------------------------------------------------- MarkMLl · 2021-01-31 14:28 TCP or UDP? If UDP, are you aware that UDP broadcasts are usually not passed through routers? What OS etc. (although I'm not sure how much it will matter, but you really should have that in any question). Are you aware that Lnet isn't very well supported these days... for something simple like this you might do better going straight to the (Berkeley) sockets API. MarkMLl ---------------------------------------------------------------------- Bas · 2021-01-31 14:36 It's a UDP broadcast on a local Network and  I get a  reply back with the mac address. I just want to know the ip address of the unit that replied so i can set up a tcp connection to that IP address. Regards, Bas ---------------------------------------------------------------------- MarkMLl · 2021-01-31 15:08 I'm not going digging into the Lnet documentation- such as it is- right now (the weather's too nice to be stuck inside), but if you were using the standard API I'd expect that you'd have a recvfrom() call which would be getting info on the sender, i.e. something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     saLength := SizeOf(sa);    messageLength := fpRecvFrom(socket, @recvBuffer, SizeOf(recvBuffer), 0, @sa, @saLength)  MarkMLl ---------------------------------------------------------------------- Remy Lebeau · 2021-01-31 20:12 Quote from: Bas on January 31, 2021, 03:18:44 pmHow can i read the ip address of the unit where the message came from ? If you are using IPv4 (the default) for your UDP socket, the sender's IP (and Port, which you will also need if you want to send a UDP reply back to the sender) can be retrieved from the TLSocket.PeerAddress and TLSocket.PeerPort properties, eg: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.udp_1_receive(aSocket: TLSocket);var  DataString : String;begin  aSocket.GetMessage(DataString); // not UDP_1.GetMessage()!  Label2.Caption := DataString;  IpAddress = aSocket.PeerAddress;  Port := aSocket.PeerPort;  // send reply to IpAddress:Port if needed...end;                           On the other hand, if you are using IPv6 instead, unfortunately I don't see any way to access the sender's IP and Port from TLSocket (without hacking it).  The peer information is present in the internal TLSocket.FPeerAddress data member, but there is no direct way to access the IPv6 portion of it, only the IPv4 portion.  Which is odd, considering that TLSocket does appear to have some support for IPv6, but that support appears to have several shortcomings. ---------------------------------------------------------------------- MarkMLl · 2021-01-31 20:21 Quote from: Remy Lebeau on January 31, 2021, 09:12:23 pmIf you are using IPv4 (the default) for your UDP socket, the sender's IP (and Port, which you will also need if you want to send a UDP reply back to the sender) can be retrieved from the TLSocket.PeerAddress and TLSocket.PeerPort properties, eg: You beat me to it :-) Noting that it returns the address as a string, which can be a bit of a pain :-( MarkMLl ---------------------------------------------------------------------- Bas · 2021-01-31 23:53 Thx that worked, regards, Bas ---------------------------------------------------------------------- danielcharles · 2021-02-12 08:36 Hi, I am Daniel, you can read the IP-address of sender In the Properties dialog box, go to the Internet headers section, find out the X-Originating-IP field, and you will get the sender's IP address as following screenshot shown. ---------------------------------------------------------------------- MarkMLl · 2021-02-12 08:46 Quote from: danielcharles on February 12, 2021, 09:36:24 amHi, I am Daniel, you can read the IP-address of sender In the Properties dialog box, go to the Internet headers section, find out the X-Originating-IP field, and you will get the sender's IP address as following screenshot shown. Daniel, stop. Go back and read the OP's root message, and you will see that he's talking about a running program so what appears in the IDE isn't really relevant. Apart from that, welcome to the forum :-) MarkMLl