Need a way to determine PC Ip address for windows and linux complie lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- wpflum · 2014-04-04 18:01 I need to determine the local ip address of the PC the program is running on but need to do it in a way that will work for both a windows and linux compile.  I saw a couple ways of doing it with winsock for windows and external commands for linux but what I'd like is something that is cross platform so that after I'm done with the program I can compile it for both operating systems without having to 'tweak' them to work.  I guess i can do something with the compile flags and have a set of functions for both systems but I'd like a more elegant solution. Thoughts? ---------------------------------------------------------------------- Leledumbo · 2014-04-05 01:26 It's been asked a few times in the forum, and I think I've given a simple solution using TFPHTTPClient.SimpleGet which should work every supported platforms, not just windows and linux. ---------------------------------------------------------------------- wpflum · 2014-04-07 13:12 Unless I'm looking at something wrong that is not a solution I can use.  I'm not looking for the external IP address of the internet connection I'm looking for the IP address of the network card itself.  I need to determine which subnet the PC is located on within our network, three stores three different subnets. ---------------------------------------------------------------------- Leledumbo · 2014-04-07 15:57 OK, in that case, you can just run and parse ipconfig (windows), ifconfig (most linux) or ip addr (arch derivatives). You have to know which connection is actually active though (LAN, WiFi, whatever). ---------------------------------------------------------------------- BigChimp · 2014-04-07 16:26 Or use the windows api to enumerate... never mind, I'm sure you'll figure it out. ---------------------------------------------------------------------- Thaddy · 2014-04-22 11:44 For the external ip I have been running a (dual) service for years: var MyIp:string; MyIp:= TFPHTTPClient.SimpleGet('http://íp.thaddy.com'); The advantage is this returns no extra's, just the ip as a string. This server is running since 2000, just in case... The service itself is running quite a few years as well. Feel free to add it to the wiki. There's another option available: http://ip.thaddy.com/simple.php The difference is that the straight subdomain tries to resolve well behaving proxies too. The simple page just returns the exposed top- level external ip.