piccaso Posted November 12, 2006 Posted November 12, 2006 i miss the opposite of TCPNameToIp() is there any? CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
PaulIA Posted November 12, 2006 Posted November 12, 2006 i miss the opposite of TCPNameToIp()is there any?Many names can resolve to a single IP address. For example, if I'm running a web server, ftp server and email server, they can all have the same IP address. You can query ARIN and get information about who owns the IP if you want. Auto3Lib: A library of over 1200 functions for AutoIt
piccaso Posted November 12, 2006 Author Posted November 12, 2006 i know that you can have multiple domains for a ip but one is allways primary... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
PaulIA Posted November 12, 2006 Posted November 12, 2006 i know that you can have multiple domains for a ip but one is allways primary...Really? And in the example above, which one would be the primary? The web server, the ftp server or the mail server? Auto3Lib: A library of over 1200 functions for AutoIt
piccaso Posted November 12, 2006 Author Posted November 12, 2006 like this... TCPStartup() ; WSAStartup inside... $sIp = TCPNameToIP("www.hiddensoft.com") $vIp = DllCall("Ws2_32.dll","long","inet_addr","str",$sIp) $vIp = $vIp[0] $vHostent = DllCall("Ws2_32.dll","ptr","gethostbyaddr","long_ptr",$vIp,"int",4,"int",2) ; 2= AF_INET If @error Then ConsoleWrite(@error & @CR) $vHostent = $vHostent[0] $vzStrptr = DllStructCreate("ptr",$vHostent) $vzStr = DllStructCreate("char[256]",DllStructGetData($vzStrptr,1)) ConsoleWrite(DllStructGetData($vzStr,1) & @LF) hiddensoft.com -> (some numeric ip) -> autoitscript.com CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
PaulIA Posted November 12, 2006 Posted November 12, 2006 like this... TCPStartup() ; WSAStartup inside... $sIp = TCPNameToIP("www.hiddensoft.com") $vIp = DllCall("Ws2_32.dll","long","inet_addr","str",$sIp) $vIp = $vIp[0] $vHostent = DllCall("Ws2_32.dll","ptr","gethostbyaddr","long_ptr",$vIp,"int",4,"int",2) ; 2= AF_INET If @error Then ConsoleWrite(@error & @CR) $vHostent = $vHostent[0] $vzStrptr = DllStructCreate("ptr",$vHostent) $vzStr = DllStructCreate("char[256]",DllStructGetData($vzStrptr,1)) ConsoleWrite(DllStructGetData($vzStr,1) & @LF) hiddensoft.com -> (some numeric ip) -> autoitscript.comYou started off with one name, resolved to an address and ended up with a totally different name. See what I mean about IP addresses can resolve to different names? Primary has no meaning when you resolve IP -> name, only from name -> IP. Auto3Lib: A library of over 1200 functions for AutoIt
piccaso Posted November 13, 2006 Author Posted November 13, 2006 i didnt expect something else... thats how that dns thing works i was just missing an autoit function that does resolving but the dllcall method is good for me... just need to wrap it up as function... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
piccaso Posted November 13, 2006 Author Posted November 13, 2006 Really? And in the example above, which one would be the primary? The web server, the ftp server or the mail server?depends on dns configurationnormaly if you have:www.host.tldsmtp.host.tldpop.host.tldit resolves to host.tld but this realy differs throu the web... CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
piccaso Posted November 13, 2006 Author Posted November 13, 2006 if your behind a router you have multiple hostnames yourself but thats a diffrerent story and i have answered my support request myself, how nice expandcollapse popupFunc _TCPIpToName($sIp,$hDll_Ws2_32 = "Ws2_32.dll") Local $vbinIP,$vaDllCall,$vptrHostent,$vzptrName Local $INADDR_NONE = 0xffffffff $vaDllCall = DllCall($hDll_Ws2_32,"long","inet_addr","str",$sIp) If @error Then Return SetError(1,0,"") ; inet_addr DllCall Failed $vbinIP = $vaDllCall[0] If $vbinIP = $INADDR_NONE Then Return SetError(2,0,"") ; inet_addr Failed $vaDllCall = DllCall($hDll_Ws2_32,"ptr","gethostbyaddr","long_ptr",$vbinIP,"int",4,"int",2) ; 2 = AF_INET If @error Then Return SetError(3,0,"") ; gethostbyaddr DllCall Failed $vptrHostent = $vaDllCall[0] If $vptrHostent = 0 Then $vaDllCall = DllCall($hDll_Ws2_32,"int","WSAGetLastError") If @error Then Return SetError(5,0,"") ; gethostbyaddr Failed, WSAGetLastError Failed Return SetError (4,$vaDllCall[0],"") ; gethostbyaddr Failed, WSAGetLastError = @Extended EndIf $vzptrName = DllStructCreate("ptr",$vptrHostent) Return __TCPIpToName_szStringRead(DllStructGetData($vzptrName,1)) EndFunc ; Internal Func __TCPIpToName_szStringRead($iszPtr, $iLen = -1) Local $aStrLen, $vszString If $iszPtr < 1 Then Return "" If $iLen < 0 Then $aStrLen = DllCall("msvcrt.dll", "int", "strlen", "ptr", $iszPtr) If @error Then Return SetError(1, 0, "") $iLen = $aStrLen[0] + 1 EndIf $vszString = DllStructCreate("char[" & $iLen & "]", $iszPtr) If @error Then Return SetError(2, 0, "") Return SetError(0, $iLen, DllStructGetData($vszString, 1)) EndFunc #include <inet.au3> ConsoleWrite("Public hostname:" & _TCPIpToName(_GetIP()) & @LF) ConsoleWrite("Local hostname:" & _TCPIpToName("127.0.0.1") & @LF) ConsoleWrite("@IPAddress1 hostname:" & _TCPIpToName(@IPAddress1) & @LF) ;~ Public hostname:85-124-175-2.dynamic.xdsl-line.inode.at ;~ Local hostname:localhost ;~ @IPAddress1 hostname:Kunibert CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
PaulIA Posted November 13, 2006 Posted November 13, 2006 depends on dns configurationnormaly if you have:www.host.tldsmtp.host.tldpop.host.tldit resolves to host.tld but this realy differs throu the web...Not wanting to pick a fight. Glad that you found something to resolve IP to DNS, but I stand by my statement that there is no such thing as a "primary" name when resolving IP -> Name. Auto3Lib: A library of over 1200 functions for AutoIt
dv8 Posted November 17, 2006 Posted November 17, 2006 Hi,I was looking for this function for a long time! Until now I was parsing the output of NBTSTAT.EXE. Thank you for creating it!!!I have one question:I need it for resolving the local network names and I tried to remove the first two ConsoleWrite lines from your example, and it stopped working.It seams that it needs to first call:ConsoleWrite("Public hostname:" & _TCPIpToName(_GetIP()) & @LF)and then:ConsoleWrite("@IPAddress1 hostname:" & _TCPIpToName(@IPAddress1) & @LF)to work. But this is a bit slow.Can you please explain why is that, and is there a way to call only _TCPIpToName(<IPAddress>)? Free Remote Desktop Software For Windows
/dev/null Posted November 17, 2006 Posted November 17, 2006 Can you please explain why is that, and is there a way to call only _TCPIpToName(<IPAddress>)? the problem is not the ConsoleWrite, but the missing TCPStartup() call before _TCPIpToName. With that it works for me. #include <inet.au3> TCPStartup() ConsoleWrite("Public hostname:" & _TCPIpToName("64.111.104.70") & @LF) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
dv8 Posted November 17, 2006 Posted November 17, 2006 the problem is not the ConsoleWrite, but the missing TCPStartup() call before _TCPIpToName. With that it works for me. #include <inet.au3> TCPStartup() ConsoleWrite("Public hostname:" & _TCPIpToName("64.111.104.70") & @LF) Cheers Kurt Thank you VERY MUCH !!! Free Remote Desktop Software For Windows
piccaso Posted November 17, 2006 Author Posted November 17, 2006 the above version in not complete, it doesent read out the aliases stroed in hostent struct. i sent a complete version to jos and if he wants to it will be in the next beta... pn me if you cant wait CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Developers Jos Posted November 18, 2006 Developers Posted November 18, 2006 the above version in not complete, it doesent read out the aliases stroed in hostent struct.i sent a complete version to jos and if he wants to it will be in the next beta...pn me if you cant wait I haven't worked much on UDF submissions lately... motivation is down a bit the last week or so doing this stuff, but no worries, it will come back and I will pick up all submissions.This one does sound useful to put in ....... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now