Deye

gethostbyname

10 posts in this topic

#1 ·  Posted

Hi,

i.e using $sIPAddress = TCPNameToIP("http://example.ddns.net")  got me error: 11004 WSANO_DATA

 which lead me to look for "gethostbyname"

Can  this function can be tweaked to work along giving it an address parameter ( presuming it can also work from out side IPs )
Running it locally with the private network address ..worked!

; https://www.autoitscript.com/forum/topic/165201-dllstructcreate-alignment-problem/?do=findComment&comment=1206048

Func _hostbyname($sAddress)
    TCPStartup()
    $pointer = DllCall("Ws2_32.dll", "ptr", "gethostbyname", "str", "")
    $pointer = $pointer[0]
    $hostent = DllStructCreate("ptr h_name; ptr h_aliases; short h_addrtype; short h_length;ptr h_addr_list", $pointer)
    $sh_addr_list = DllStructCreate("ptr", DllStructGetData($hostent, "h_addr_list")) ;We get the Pointer to an array of addr
    $inaddr = DllStructCreate("ptr", DllStructGetData($sh_addr_list, 1)) ;we get the array[0] ;if you want to get another index just plus 4
    $uint = DllStructGetData($inaddr, 1)
    $ret = DllCall("Ws2_32.dll", "str", "inet_ntoa", "UINT", $uint)
    Return $ret[0]
    TCPShutdown()
EndFunc   ;==>_hostbyname

 

Share this post


Link to post
Share on other sites



#3 ·  Posted

jguinch,

Its an address that doesn't work for me with TCPNameToIP 
the function in question is for gethostbyname  ..what else
 

Thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted

@Deye As mentioned by @jguinch, example.ddns.net does not exist. It is the same as trying to get god.universe's IP address


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#5 ·  Posted

I take it this function maybe only good for getting the address's IP in case the requester has the same (external ip) ?

what do you get when running TCPNameToIP() against your own ddns.net which is linked to the computer you are running the command off ?

example.ddns.net is of course  fake (i.e: example)

Share this post


Link to post
Share on other sites

#6 ·  Posted

24 minutes ago, Deye said:

what do you get when running TCPNameToIP() against your own ddns.net which is linked to the computer you are running the command off ?

What is ddns.net?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#7 ·  Posted

Use of Dynamic DNS needs an implementation ..

Anyone, please confirm do you get any ip for this address:  

MsgBox(0,"", TCPNameToIP("http://scriptlistener.ddns.net"))

 

Share this post


Link to post
Share on other sites

#8 ·  Posted

Your dynamic DNS address will always point towards the host computer's external IP address.

2 minutes ago, Deye said:

Anyone, please confirm do you get any ip for this address:  

You should remove http:// because its a protocol identifier used by browsers, domain names don't need any protocol to associate with.

I tried your snippet, and here is the result: 4VwG2ND.png

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#9 ·  Posted

Well then that explains to me =  trouble at its absence

Thanks again for all the great help !

Share this post


Link to post
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