Paul Thomas Posted August 4, 2011 Share Posted August 4, 2011 With only using BlitzMax, is there a way to get your own IP address? All that I've tried it just gives me the default localhost address. Thanks. Quote Link to comment Share on other sites More sharing options...
Canardia Posted August 4, 2011 Share Posted August 4, 2011 You can create a batch file in bmx which launches ipconfig.exe and redirects the output to a text file, which you then can read from bmx. That's better than reading directly from the registry using win32 api calls, because it's compatible with linux and mac too. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
macklebee Posted August 4, 2011 Share Posted August 4, 2011 or you can cheat and goto an outside source file:TStream = OpenFile("http::checkip.dyndns.org") ip:String = ReadLine(file) CloseStream(file) ip = Replace(ip, "<html><head><title>Current IP Check</title></head><body>Current IP Address:", "") ip = Replace(ip, "</body></html>", "") Notify(ip) Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Paul Thomas Posted August 4, 2011 Author Share Posted August 4, 2011 Thanks for the help guys. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted August 4, 2011 Author Share Posted August 4, 2011 Going to use your method, Mack, since then I can easily check if I'm online or not. This is for a tool so I don't mind the address opening though I'm probably going to change it to connect to my own server address. Thanks, Mack. Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 4, 2011 Share Posted August 4, 2011 Going to use your method, Mack, since then I can easily check if I'm online or not. This is for a tool so I don't mind the address opening though I'm probably going to change it to connect to my own server address. Thanks, Mack. not a problem, glad to help... and thats alot easier than trying to parse the results of ipconfig, which would be almost impossible on various computers... not to mention ipconfig wouldn't give you what you are looking for if you are behind a router. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Canardia Posted August 5, 2011 Share Posted August 5, 2011 It depends, if you're doing a LAN game, then you need the internal IP from ipconfig, but for internet games the internet IP address is better. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Cole Chapman Posted August 5, 2011 Share Posted August 5, 2011 To get your Local IP: Print HostName(localhost) Print DottedIP(HostIp(HostName(localhost))) Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted August 5, 2011 Author Share Posted August 5, 2011 Thanks Cole, that's exactly what I was looking for! Don't remember what I was trying before but HostIp() kept returning 127.0.0.1 and then I decided to post this thread, lol. Quote Link to comment Share on other sites More sharing options...
Cole Chapman Posted August 5, 2011 Share Posted August 5, 2011 No problem, glad I could help Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 18, 2011 Author Share Posted December 18, 2011 Hate to bring up this dead horse of a thread, but I've had to revert to Macklebee's suggestion since "DottedIP(HostIp(HostName(localhost)))" returns the routers IP when the real IP is required. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.