Jump to content

@IPAddress1 and 127.0.0.1


j0kky
 Share

Recommended Posts

Hi guys,

I need to know, if anyone knows, when the macro @IPAddress1 returns 127.0.0.1 (as documentation says), if the real LAN IP (ex 192.168.x.x) is always returned by @IPAddress234.

The problem exists if the PC is connected to the LAN, @IPAddress1 returns 127.0.0.1 but no macro returns the real IP.

It would be useful to know which API is called by @IPAddress1, I suspect GetAdaptersInfo but I'm not sure.

Link to comment
Share on other sites

@JohnOne: So if I have a local Proxy server can it happens:

@IPAddress1 = 127.0.0.1

@IPAddress2 = 0.0.0.0

@IPAddress3 = 0.0.0.0

@IPAddress4 = 0.0.0.0

@Jguinch: Thank you! Probably it uses getaddrinfo or the old gethostbyname + inet_ntoa

Edited by j0kky
Link to comment
Share on other sites

instead, you can use a (slow) WMI query :

#Include "Network.au3" ; in my signature

Local $aInfos = _GetNetworkAdapterInfos()
For $i = 0 To UBound($aInfos) - 1
    If $aInfos[$i][16] <> "" Then ConsoleWrite($aInfos[$i][8] & @TAB & $aInfos[$i][16])
Next
Link to comment
Share on other sites

@JohnOne: I'm bulding a LAN chat, I don't care about WAN address (external IP) but I'm looking for the current LAN address.

@IPAddress returns for me the right LAN address but, as documentation says, in certain cases @IPAddress1 reports the loopback address 127.0.0.1.

My question is: in those cases, can I be sure that the other IPAddress macros report the real LAN address 192.168.x.x ?

EDIT: Obviously the question is related to a PC inserted in a LAN.

Edited by j0kky
Link to comment
Share on other sites

Tricky one to answer that, and I imagine only a code dev could really answer it.

I get the feeling that the help file comment could be be a throwback from the win9x.ME days, but I obviously cannot be certain of that, I have never come across the macro returning loopback address.

I fear that you might have to actually have access to such a case machine to determine and address any potential bugs, other than looping through the macro's and testing for a valid address.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@j0kky : WMI doesn't need admin rights for this read operation. _GetNetworkAdapterInfos() works with a standard account.

But I agree, it's less clean than an integrated function or a WinAPI based one...

Link to comment
Share on other sites

@JohnOne and Jguinch: thank you for your time, I can't access to a win9x PC but MSDN says:

IPConfig

This directory contains a sample program that demonstrates how to programmatically retrieve IPv4 configuration information similar to the IPCONFIG.EXE utility. It demonstrates how to use the GetNetworkParams and GetAdaptersInfo functions. Note that the GetAdaptersInfo function only retrieves IPv4 information.

So I think I will loop trought the macro searching a valid address, if no result I'll implement a GetAdaptersInfo-based snippet.

Edited by j0kky
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...